in reply to Getting a funny newline that was not there before

This has nothing to do with your newline problem.

I happened to notice this curious snippet in your code:

my %hash = map { $_ => 1 } @files; @files = keys %hash;
Are you intentionally using the intermediate hash to reorder your @files array? I can find no other usage of your %hash variable in your code. If so, List::Util::shuffle will provide more randomness from run-to-run, and it would also make the intent of your code more evident:
use List::Util qw(shuffle); @files = shuffle(@files);

Replies are listed 'Best First'.
Re^2: Getting a funny newline that was not there before ([OT] shuffle)
by BrowserUk (Patriarch) on Mar 26, 2010 at 00:54 UTC
    Are you intentionally using the intermediate hash to reorder your @files array?

    He could be de-duping the list.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Excellent point. I guess this demonstrates the value of giving variables meaningful names. If %hash had been named %seen or %uniq, then the intent would be much clearer.
Re^2: Getting a funny newline that was not there before ([OT] shuffle)
by MikeDexter (Sexton) on Mar 30, 2010 at 20:42 UTC

    I am using the hash to remove duplicate entries from the list.