in reply to Re: Re: I'm so confused
in thread I'm so confused

You might want to be using the <> operator here. <> reads from the files passed in ARGV (if they exist) or from STDIN otherwise. This means that you can have this behaviour with no extra effort if you want it in the future.

It'll certainly save you from having to worry about opening each of those files and the like. So your code could simplify to:

#!/usr/bin/perl -w use strict; use diagnostics; if(-e "out.txt") { # complain about file. } my @out; while(<>) { chomp; push @out, lc($_); } # do stuff with @out: @out = sort @out; # print it (to STDOUT for the moment) print join("\n", @out);
I agree with everyone else here, that you probably don't want to be inserting the newline until you're ready to output the data. If you decide, for some reason, later to reverse all the characters on each of your lines or some such, that newline character can get in the way.

Good luck.