Your perl is what I affectionally call a "glorified batch file." Which is fine ... as long as you don't want to maintain it.

print `dir /b $source\\*.txt > $source\\dir_list.lst`; #$source is d +eclared just before the sub is called
Rather than this convoluted line which prints nothing, but calls CMD.EXE to do a bunch of work, why not just use glob to get the list directly?
@list = glob "$source\\*.txt";
Though those backslashes do look mighty ugly ... you can either use / instead (slightly more portable should you ever need to move to a unix variant), or convert to File::Spec and become platform agnostic. Well, at least for creating file paths.

Another issue is just that you're probably not using strict or warnings. But that likely comes from the perl-as-a-batch-file-language approach you're using. This manifests as not passing in parameters to functions. There's no point in having functions if you don't use parameters to pass in values to work with. So, instead of setting $source before calling childsup, pass $source in as a parameter. This will make things easier to test and to reuse. Especially the part about putting use strict; and use warnings; at the top of your script.

And "$cnt = $cnt + 1;" is normally written as "$cnt++;" (it's so common that there's a shortcut for it). I highly suggest reading Learning Perl - it'll help you a lot.

All this probably doesn't quite solve your problem, but can make your code easier to use and read. As to your actual problem, I have to wonder if you are running the script as yourself or as another user, and that may cause permission problems. In my day job, my perl code's primary responsibility is copying files over the network (via samba or nfs, so I don't really worry about it), on Windows, Linux, AIX, Sun, and HP. Multiple GB at a go. And I really don't run into this problem, even using File::Copy for the actual copy operation. So I have to start by wondering about actual permissions - who the script runs under. I suspect you may be using the System account for your normal execution, and this would be a problem if true.


In reply to Re: Has my Perl Go Crazy? by Tanktalus
in thread Has my Perl Go Crazy? by Xanthis013

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.