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;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|