Next | Program Repair Shop | 54 |
next if $File !~ /^\d{5}/; my $n = substr($File, 0, 5); if ($n > $Highest) { $Highest = $n; }
This reads the file 123456foo as beginning with 12345
Perhaps that will never be a problem
It might even be correct behavior
If not, use
next if $File !~ /^(\d{5,})/; if ($1 > $Highest) { $Highest = $1; }
Some might prefer
$Highest = $1 if $1 > $Highest;
# or
$Highest = ($1 > $Highest) ? $1 : $Highest;
Try it Both Ways
Really try it
It's easier to see than to think
Next | Copyright © 2002 M. J. Dominus |