First, I'd use more than one space for indentation. I use 4 because I like the way it discourages overly deep nesting of code. Even 2 or 3 would be quite a bit better than 1, IMO.
$Traps{"$Fields[6]"} = [ $Expiration,$Fields[2],$Fields[5],$Fields[7] ]; can be written $Traps{$Fields[6]} = [ $Expiration, @Fields[2,5,7] ]; Putting in too many quotes can bite you (though using it as a hash key also does the stringification which would bite you in the same way in this case -- changing an object into a string) so be careful of it.You can make the code clearer using a few constants:
(these make no difference in the running time of the code since they get optimized away at compile time). I'd also avoid 'unless' so push @GrepList,$Traps{$trap}[3] unless (($Traps{$trap}[0] < $Now && $Traps{$trap}[1]) || $trap eq "SIZE"); becomessub EXPIRE() { 0 } sub WHATEVER() { 1 } sub FOOBAR() { 2 } sub FILENAME() { 3 }
for example (I find spacing more effective at conveying grouping than parens, YMMV).push @GrepList, $Traps{$trap}[FILENAME] if $trap ne "SIZE" and ! $Traps{$trap}[WHATEVER] || $Now <= $Traps{$trap}[EXPIRES];
Don't use map unless you want the list that it builds: map { $MaxLen = length($_) if length($_) > $MaxLen } @GrepList; becomes
If you really have a need for single-line code (which is a mistake in my book), then remove the newlines.for( @GrepList ) { $MaxLen = length($_) if length($_) > $MaxLen; }
Use local( $/ )= \$BufferSize; and you can drop the $/ = "\n"; line.
So no speed improvements to offer. (:
- tyeIn reply to Re^3: Shell Script Woes (review)
by tye
in thread Shell Script Woes
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |