$dir doesn't need to be interpolated into a string, it is already.
$_ doesn't have any useful contents inside the sub and it certinally isn't an array, or even a reference to and array, so foreach doesn't help anything.
Chaning the contents of the variable $file would only help if you were itterating over array elements in the foreac, but you've not got an array to itterate over.
The following code may get you headed in the right direction:
use strict; use warnings; use File::Find; my $dir = shift; find(\&change_ext_if_file, $dir); sub change_ext_if_file { my $file= $File::Find::fullname; return if -d $file; # skip directories return if $file !~ /\.pdf/i; # Ignore anything that's not a .pdf (my $newName = $file) =~ s/pdf$/doc/i; #do whatever needs to be done with the new filename - rename maybe +? #rename $file, $newName; }
In reply to Re: No Substitution Happening
by GrandFather
in thread No Substitution Happening
by coolboarderguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |