David Gilden wrote:
> Hello,
Hello,
> In the Script below the line: last if ($num >= 35)
> is giving me this error: Use of uninitialized value in int
>
> How do I avoid this error?
You are using the results of a regular expression match without verifying that
the regular expression matched successfully. Don't do that.
> my @files contains: Gambia001.tiff through Gambia100.tiff
>
> #!/usr/bin/perl -w
>
> my @files =<*>;
> $tmp= 1;
>
>
> for (@files){
> my $old = $_;
> $_ =~ /(\d+)/;
> $num = int($1);
if ( /(\d+)/ ) {
$num = int $1;
}
Or perhaps:
next unless /(\d+)/;
$num = int $1;
Or maybe only work on files that actually have digits in them:
my @files = <*[0-9]*>;
> #$_ =~s/Gambia_Pa_Bobo_kuliyo_\d+/Gambia_Pa_Bobo_kuliyo_$tmp/i;
> print "$num\n";
> #$tmp++;
> last if ($num >= 35);
> # rename($old,$_);
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>