I need help debuging this code. I received a variable call $fixed_path. this path containes a directories and subdirectory which I search for a RTF file. It is not working now. for example H:\08\00004D04.009 Is there any way that anyone could take a look at the code and let me know what is missing to make it work??
use File::Find; use File::Copy; sub find_copy_rename { my @dir = $fixed_path; my @get_directory = substr($fixed_path,-12); my $get_each_directory = @get_directory; my $dir = @dir; my $current_path = 'C:\\temp\\'; if ($File::Find::dir ne $dir) { $File::Find::prune = 1; return 0; } return 0 if ($_ !~ /\.rtf$/); copy($File::Find::name, $current_path.$_) or die "Failed to copy $ +_: $!\n"; return 1; } find(\&process_files, $dir); my @process_file = &process_files; my $get_files = grep { !-d } @process_file; foreach my $get_files (@process_file) { my $newfile = $get_files; $newfile =~ s/\$mrn.$get_each_directory.'.'.rtf$/word1.rtf/; if (-e $newfile) { warn "can't rename $get_files to $newfile: $newfile exists\n"; } elsif (rename "$newdir/$get_files", "$newdir/$newfile") { print "file was renamed to $newfile\n" } else { warn "rename $get_files to $newfile failed: $!\n"; } }

In reply to Find, copy & rename by skyler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.