in reply to Pearls (not really) of Perl programming
Everyone loves to post bad examples from other peoples' code. But I will [once again] bravely delve into my own code archives for terrible examples!
This is at the beginning of a script that I must have written shortly after I learned about use strict. I didn't really understand lexical scope, I just wanted the errors to go away. Can we say "missing the point"?
my($all,$com,$csv,$ctr,$desc,$dir,$fname,$found,$fsize, $line,$longline,$null,$one); my($parm,$parms,$pattern,$seekrc,$value); my(@coms,@csvin,@grep,@parms,@seekrc);
Here's another fun one. I can think of one or two easier ways to do this nowadays....
($start,$stop,$adv,$desc) = split(/\,/,$line); $start =~ s/^\s+//g; $stop =~ s/^\s+//g; $adv =~ s/^\s+//g; $desc =~ s/^\s+//g;
Or how about something like this. I guess I didn't yet understand how to access nested hashes, because the use of %temphash is just bizarre (trimmed for pasting):
while(defined($line = <IN>)) { ... $temphash{'size'} = $size; $temphash{'crc'} = $crc; if($dir eq "" || $csvdirs == 1) { ... $temphash{'dir'} = $good; } elsif($csvdirs == 2) { ... $temphash{'dir'} = $good . "/" . $dir; } else { $temphash{'dir'} = $dir; } $bighash{$name} = { %temphash }; }
I could go on all day, to my own humiliation. I'll leave it at that though. Perhaps others will now be tempted to post their own bad code, rather than someone else's. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pearls (not really) of Perl programming
by hardburn (Abbot) on Nov 24, 2004 at 18:45 UTC | |
by revdiablo (Prior) on Nov 24, 2004 at 19:08 UTC | |
by exussum0 (Vicar) on Nov 25, 2004 at 00:15 UTC | |
|
Re^2: Pearls (not really) of Perl programming
by Nkuvu (Priest) on Nov 25, 2004 at 14:04 UTC | |
by Anonymous Monk on Nov 25, 2004 at 18:17 UTC |