Well, the use of lexical variables or --in other words-- the
my operator is something you should look into very quickly. It makes for very clean programming, allowing you to use variables in sub-routines and loops without having them effect anything outside of the sub-routine or loop. Read the
Private Variables via my() chapter in
perldoc perlsub if you want to know more.
That being said, you can drop all the my keywords in my program and if you also delete the use strict; it will still run fine, but you really, really should look into the use of my (and use strict;). It wil save you a lot of time and effort over and over again and will guard against stupid and silly mistakes.
The way my program is written, it will always only read one line of the file in memory at any time, so your files can actually have millions of lines and it will still work.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
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.