Dear Monks, I'm seeking your wisdom. I'm facing with two issues. 1.- I'm passing a variable from a sub routine call main () to another one. The variable is call $all_directories. This variable has a list of paths that I will use to search .htm files for example:
c:\inetpub\test1 c:\inetpub\test2 c:\inetpub\test3
Every path is different than the other, so I'm trying to pass it one by one to search for .htm files in each different directory. I get an error "useless use of private variable in void at test.pl line 37 Global symbol "$all_directories" requires explicit package name" My second issue is how do I rename files that are being copy to another directory dynamically without open and closing the directory that are being copy to?? Please Help!!! Here is my code
use File::Find; use File::Copy; my @directory = $all_directories; my @sourcefiles; my $srcfile; find(\&sourcefind, @directory); sub sourcefind { open(FL, $File::Find::name); push @sourcefiles, $_ if -f and /\.htm*/ ; close(FL); } foreach $srcfile (@sourcefiles) { copy( sub {print "$_ target found\n" if -f and /\Q$srcfile\E/;}, 'C:\temp'); }

In reply to rename files dynamically by Anonymous Monk

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.