#!/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...
In reply to Re^4: No Substitution Happening
by coolboarderguy
in thread No Substitution Happening
by coolboarderguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |