On Fri, 2006-08-11 at 18:54 +0200, Adriano Allora wrote:
> Actually I use a while loop to extract the numbers:
> 
>       while (defined($file = readdir(DIR)))
>               {
>               next if $file =~ /^\.\.?/;
>               $file =~ s/[A-Z]+(\d+).txt$/$1/;
> # ????
>               }
> 
> but I ignore how to select the last number.
> Someone can suggest to me a way to work?

use strict;
use warnings;

my ($file, $number)

while (defined($file = readdir(DIR))) {
  if($file =~ m/[A-Z]+(\d+)\.txt/ ) {
    if( $1 > $number ) { $number = $1; }
  }
}

print $number, "\n";

__END__

HTH
 
-- 
Joshua Colson <[EMAIL PROTECTED]>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to