What's with the
for ( 1 .. $i ) { my $line = `head -$_ $filename | tail -1`; print $line; }
As any fule no, that should be written as
my $line; my $ln = 0; for ($ln = 1; $ln <= $i; $ln = $ln + 1) { system ("head -$_ $filename | tail -1 > file.tmp"); open(FILE, "file.tmp"); my $tmp = $_; while (<FILE>) { chomp; print $_; print "\n"; } close FILE; $_ = $tmp; }
I'm very proud of the masterful technique used to avoid clobbering $_
• another intruder with the mooring in the heart of the Perl
In reply to Re: Plain old bad code
by grinder
in thread Plain old bad code
by HuckinFappy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |