- 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.
|
#
¿
Apr 1, 2008 06:46
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 7, 2024 12:08
|
|
- 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?
|
#
¿
Apr 9, 2009 22:23
|
|
- Kidane
- Dec 15, 2004
-
DANGER TO MANIFOLD
|
I always read all the 'preg' functions in PHP as 'pregnant'.
|
#
¿
Apr 5, 2010 21:47
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 7, 2024 12:08
|
|
- Kidane
- Dec 15, 2004
-
DANGER TO MANIFOLD
|
code: //$letters = "0123456789";
I love it.
|
#
¿
Oct 18, 2010 09:34
|
|