Everyone has posted good information about regular expressions, so I won't dwell on that. But I will point out that you don't need to use a shell command to get the time. Right now your code reads:
chomp($DATE=`date +%d%b%y`);
Where the backticks quietly go off and spawn another process to get the date for you. Very slow in comparison to the Perl way: localtime(time); Seeing that you just want the day/month/year, you can do this by saying:
my @date = (localtime(time))[3..5]; # Get the date. (18, 6, 10
+0)
++$date[1] and $date[2] += 1900; # Make it reader friendly
for( @date[0..1] ){ $_ = "0$_" if 10 > $_ } # Add 0 prefixes as needed
+.
my $DATE = join '', @date; # now 18072000
As usuall, this can be made more tight and efficient, I'm not playing Perl Golf, just showing you don't need to make a shell call to get the date. For more info read perldoc:
localtime.
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.