Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: Re: I'm so confused by st4k
in thread I'm so confused by st4k

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2021-10-23 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?