I may be wrong, I am kind of new at this, but I believe there is one more problem with your regex. If you are trying to match 5 and only 5 digits, you need to drop the comma as well. Page 68 of the nutshell book says the {n,} will match at least 5 or more. You need to use {5} to match 5 and only 5 digits.
unless ($num =~ /^\d{5}$/) {
Even with an anchor /^\d{5,}$/ will match any line that starts with at least 5 numbers but contains more than 5 numbers.
Update: I see after re-reading your problem that you do want 5 or more. I was to excited about regex. It is the topic of discussion this week in a class I am taking.
Yoda
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.