The structure is quite static, you could also use the
__DATA__ part of your script. A possible approach could be:
#!/usr/bin/perl
# Load data inside %times hash
my %times;
while (<DATA>) {
next unless /\S/; # just in case...
my ($month, $weeknum, $day, $val) = split /;/;
$times{$month}{"wk$weeknum"}{$day} = $val;
}
# ... all your program here ...
__DATA__
May;1;Mon;24.50
May;1;Tues;23.40
May;1;Wed;22.40
May;1;Thu;25.01
May;1;Fri;24.10
... and so on...
However, you should decide which is the best data structure suitable for what you intend to do with your data, then think about how storing it somewhere. You can also look for
Storable or
XML::Simple for ways to do the latter.
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
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.