in reply to No Substitution Happening
$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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: No Substitution Happening
by coolboarderguy (Acolyte) on Mar 24, 2006 at 08:07 UTC | |
by GrandFather (Saint) on Mar 24, 2006 at 08:27 UTC | |
by coolboarderguy (Acolyte) on Mar 24, 2006 at 09:03 UTC | |
by coolboarderguy (Acolyte) on Mar 24, 2006 at 09:04 UTC | |
by coolboarderguy (Acolyte) on Mar 24, 2006 at 09:22 UTC | |
by fishbot_v2 (Chaplain) on Mar 24, 2006 at 16:54 UTC |