Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

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

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

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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2021-11-27 21:23 GMT
Find Nodes?
    Voting Booth?

    No recent polls found