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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
  • open (INFILE, "$ARGV[1]") or die "$ARGV[1] cannot be openned : $!"; while ($source_file =~ /(\d)\s+(\d)\s+(\d)\s+(\w+)/)
    Maybe (probably) in your head there's a connection between INFILE and $source_file, but not in your script.
    For Perl, they're unrelated…
  • if ($ARGV[0] eq "-a")
    How do you know your $ARGV[0] really equals "-a"?
    What happens if it doesn't?
    I recommend to add an else block with a print "whatever\n", at least while you're still experimenting.
  • Many of the suggestions to your questions include using strict and warnings. Although this seems to impede or slowing down one's development, I recommend it, too:
    • Yes, the time it takes before your script "runs", will be longer
    • The time until your script works correctly, will be shorter
    One of strict's messages is confusing for beginners:
    Global symbol "$x" requires explicit package name
    should read
    Do you really want "$x" to be a global symbol? Better declare it with my
If you are new to Perl, you might like diagnostics, which won't throw more errors, but messages that (hopefully) are more informative. So, your script(s) should start with
use strict; use warnings; use diagnostics;

In reply to Re^3: Sort alphabetically from file by soonix
in thread Sort alphabetically from file by edujs7

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 cooling their heels in the Monastery: (5)
As of 2022-10-07 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (30 votes). Check out past polls.

    Notices?