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. :-)
In reply to Re: Pearls (not really) of Perl programming
by revdiablo
in thread Pearls (not really) of Perl programming
by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |