Ryan Moszynski wrote:
hi,

Hello,

i'm using a perl script i found

You should be careful with stuff you find lying around.

to change the names of batches of
files.  The program works as is but it's giving me a weird warning.
I'm familiar with $_, but not $_[3].  Can someone explain what $_[3]
is, and how i can get this script to stop throwning the warning?

$_[3] is the fourth element of the array @_.


i found the file here:

http://noisybox.net/computers/eren/

file download link:
http://noisybox.net/computers/eren/eren.pl

Did you read the second line of that file?

# this program sucks and is a total hack and needs TONS of work...


warning thrown:
Use of uninitialized value in pattern match (m//) at C:\pPerl\eren.pl line 82.

This means that the fourth element of the array @_ contains the value undef.


(i changed the file a bit so it won't be the same line number if you
checkout the whole file)

code from my file:

76 foreach my $file (@files){
77      next if -d($root . $file);
78      
79      next if (($preview) and not ($file =~ /$filefilter/));
80      @_ = split /\//, $replacestr;
81      my $icase = '';
82      ($_[3] =~ /i/) and $icase = 'i';
#**************************************************
83      my $cmd = sprintf("\$file =~ /%s/%s;", $_[1], $icase);
84      
85      next if not eval $cmd;

As the comment says, this sucks. You can accomplish the same thing without using eval.


86      
87      $preview and print "PREVIEW: ";
88      $matchct++;
89      
90      my $oldfile = $file;
91      print "$oldfile --> ";
92      $file =~ eval " \$file =~ s$replacestr;";
93      print "$file\n";
94      $preview and next;
95      rename($root . $oldfile, $root . $file) or print "Failed to rename
$root$oldfile\n";
96 }



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to