in reply to loop issue...

As a side note, you may want to add or die clauses after your chdir, opendir etc. And you should probably swap open $out to a three-argument form like you have for your other open statements.

Replies are listed 'Best First'.
Re^2: loop issue...
by Fletch (Bishop) on Mar 20, 2009 at 15:22 UTC

    Sounds like awfully familiar advice, doesn't it OP? :)

    He's at least checking your open calls which is good, but he'll be kicking himself n months hence when he has to spend time chasing down why things don't work that a simple opendir( FOO, $dir ) or die "opendir '$dir': $!" would have caught.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      The OP copied the lines for the open calls that I provided -- but skipped the rest of the script. Granted I missed the check on the readdir, but I also noted that (and at least failure there would just mean that @files would be empty, rather than trying to alter files in the wrong directory).

      I had hoped that the OP would see what was intended with the advice given, but I think that's too much to ask. I was toying with the idea of completely revising the script (I have a current script that's taking a very long time to execute, so have some downtime while I wait for it) but I think it would be rather pointless.

      I got the right output. Thanks!
Re^2: loop issue...
by Bloodnok (Vicar) on Mar 20, 2009 at 14:54 UTC
    ...or, alternatively, use autoload; autodie; - which would have the effect of die()ing if a built-in fails, thus not unduly cluttering the code.

    Update:

    Thanx to Fletch, I did in fact mean autodie

    A user level that continues to overstate my experience :-))
Re^2: loop issue...
by lomSpace (Scribe) on Mar 20, 2009 at 16:34 UTC
    Thanks for the help. I got the right output!