http://www.perlmonks.org?node_id=127225


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

This place rocks! I didnt expect such prompt replies :-)
The thing is I want each element in the array to be seperated by newlines so that when the script outputs the final list it will be nice and orderly, one word per line.
What the script does is read from @argv some files that it will read into an array, lowercase, sort, remove dups (not done yet) and then output the final array to out.txt
Is there a way to "unchomp" an array making sure that each element has a newline (but not add one if it already does) or something like that?
Thanks to everyone who replied
Im reading also while Im trying everyones ideas
#!/usr/bin/perl use strict; use warnings; use diagnostics; my @out; my $num = scalar(@ARGV); if (-e "out.txt"){ print "Please move or rename out.txt\n"; exit 0; } for (my $i = 0; $i < $num; $i++) { open (FH, "$ARGV[$i]") || die "Cant open: $!"; while (<FH>) { push (@out, lc); } close FH || die "Cant close: $!"; } print sort @out