Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Kidane
Dec 15, 2004

DANGER TO MANIFOLD

Triple Tech posted:

These things, as Perl programmer, piss me off:
code:
@stack = ();
for ($i = 0; $i < scalar @elements; $i++) {
  $temporary = do_something_to $elements[$i];

  push @stack, $temporary;
}
It's abundantly clear this person doesn't know about scope, the context-sensitive return value of an array, foreach loops, and map. God drat.
code:
print HANDLE "This one also demonstrates something else.";
print HANDLE "This programmer doesn't know how to use select.";
print HANDLE "Nor does he know what a heredoc is.";
print HANDLE "You get paragraphs of text that look like this.";
print HANDLE "For no reason, really.";
Point is, for you non-Perl folk, is that this poo poo could have been written in a more concise, more native-to-Perl fashion.
While I am paid to write Perl, I am by no means an expert. However, I'm of the opinion that there is nothing inherent to Perl which requires overly-concise code. My boss looked at some code I wrote and said "it's very straightforward" which I take as a compliment although I suspect many Perl programmers wouldn't. :) My code tends to look like this:

code:
my $parse_mail = Email::Simple -> new( $email );
my $sender = $parse_mail -> header( "From" );
my $jira_summary = $parse_mail -> header( "Subject" );
my $jira_description = $parse_mail -> body;
I know of the more Perl-like way to write that, I just don't care. Someone here described my Perl as "awkward" which may very well be accurate.

Adbot
ADBOT LOVES YOU

Kidane
Dec 15, 2004

DANGER TO MANIFOLD

Triple Tech posted:

Then you're no friend of mine. :colbert: There's a difference between being concise and golfing (which Perl folk love to do) and this isn't golfing. The entire field of computer science has been about a power versus concision payoff. And if you can't see that, then you're hopeless.
code:
my $parse_mail       = new Email::Simple($email);
my $sender           = $parse_mail->header('From');
my $jira_summary     = $parse_mail->header('Subject');
my $jira_description = $parse_mail->body;
Hm.

I hate to admit it, but your way is much easier to read, and perltidy agrees with you. Like I said, I'm no expert, and I'm not married to my style of coding.

Kidane
Dec 15, 2004

DANGER TO MANIFOLD

Trammel posted:

Why it copies the contents of each row into another variable? .. :iiam:

Because dereferencing is just so hard!

Kidane
Dec 15, 2004

DANGER TO MANIFOLD

Beardless Woman posted:

code:
if ($line =~ /#/ || length($line) < 2) { #we also ignore any lines that are not right
    #Just a holder place so i don't have to do reverse logic
}
else {
    #print "$line\n";	 #This works right
    push (@servers, $line);		
}
code:
my @logfile = <LOGREAD>;
foreach my $logline ( @logfile) {
   chomp($logline);
   print SENDMAIL "$logline\n ";
}
And this guy's code is actually in production.

Hahahaha, I hadn't seen the first one, that's awesome. What the hell is reverse logic? Using !~ instead?

Kidane
Dec 15, 2004

DANGER TO MANIFOLD
I always read all the 'preg' functions in PHP as 'pregnant'.

Adbot
ADBOT LOVES YOU

Kidane
Dec 15, 2004

DANGER TO MANIFOLD
code:
	//$letters = "0123456789";
I love it.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply