my code was:
#!c:/perl/bin/perl
open (INFILE,"c:/playgnd/sql_result_cf.txt") || die("Could not open fi
+le!");
while( <INFILE> ) {
next if $. == 1; # skip first line
chomp;
my %F;
@F{qw(msc_name chunum date count_per_date)} = split /\s*,\s*/;
$Data{$F{date}} = { }
unless exists $Data{$F{msc_name}};
$Data{$F{date}}->{$F{msc_name}} = [('')x5]
unless ref( $Data{$F{date}}->{$F{msc_name}});
${$Data{$F{date}}->{$F{msc_name}}}[$F{hour}] = $F{count_per_hour};
}
foreach my $date (keys %Data) {
foreach my $msc_name (keys %{$Data{$date}}) {
print join(",", $date, $msc_name, @{$Data{$date}->{$msc_name}}),
+"\n" ;
}
}
close(INFILE);
edited by ybiC: balanced <code> tags
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.