in reply to Find, copy & rename

"Not working" is pretty vague -- can you narrow it down? Does it not find the appropriate files? Does it find them but not rename them properly? I see some variables that are undeclared ($get_each_directory, $mrn).. is this all your code? A few things I noticed off the bat though:         my $current_path = 'C:\\temp\\'; Either escape your backslashes or use single quotes, but not both.
my $get_files = grep { !-d } @process_file; foreach my $get_files (@process_file) {
Do you mean to iterate through each of the non-directories? Then you probably meant foreach my $get_files (grep { !-d } @process_file)

        } elsif (rename "$newdir/$get_files", "$newdir/$newfile") { I'm not a win32 Perl user, but I'm not convinced using forward slashes will work here.

Also, I'm not sure what's the reasoning with the assignments from scalar to array and back to scalar again at the top of your code.

blokhead

Replies are listed 'Best First'.
Re: Re: Find, copy & rename
by skyler (Beadle) on Feb 24, 2003 at 05:32 UTC
    Blokhead, The problems I'm having is passing $fixed_path to sub routine (sub find_copy_rename) my code works independantly but now I'm trying to make it work dynamicall by reading a file and getting values out of the file like a file path , certain numbers , etc. I tried to compile it but it gives me $dir, $get_each_directory & $newdir "requires a special package name" I'll appreciate your help.

      The documentation of File::Find says:

      WARNINGS

      If you run your program with the -w switch, or if you use the warnings pragma, File::Find will report warnings for several weird situations. You can disable these warnings by putting the statement

          no warnings 'File::Find';
      

      in the appropriate scope. See perllexwarn for more info about lexical warnings.

      Perhaps that is the "cause" of your weird error messages.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law