in reply to Re^3: No Substitution Happening
in thread No Substitution Happening
#!/usr/bin/perl use strict; use warnings; use File::Find; my $dir = shift; #dir = the argument given on the command line (./fi +lechng.pl testdir) find(\&change_ext_if_file, "$dir"); #loops through dir scooping up all + it finds sub change_ext_if_file { #called function my @files = @_; #creates array foreach my $file (@files) { ##loops through the array @files and + places each file into scalar $file if ((-f $file) && ($file =~ /pdf$/)) { #checks if file and if e +nds with pdf $file =~ s/pdf/doc/; #replaces pdf with doc } } }
Is this closer? It runs with no errors, but, still no changes. Cheers
EDIT: Good lord, I'm a dimwit at best. That above looks for the string inside the file, not changes the name. I now see my wrong in this...sorry for not picking that up any earlier than now. Cheers, again coolboarderguy...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: No Substitution Happening
by fishbot_v2 (Chaplain) on Mar 24, 2006 at 16:54 UTC |