in reply to Re^2: Help! Stuck on methods to count file size.
in thread Help! Stuck on methods to count file size.

here's the code
I also changed my previous mistakes with dereferencing
feed back if there are any mistakes
much appreciated
%jan = ('max' => 0, 'bytes' => 0); %feb = ('max' => 0, 'bytes' => 0); for (6..31) {$m[$_] = \%jan} for (32..59) {$m[$_] = \%feb} while(<DATA>){ ($day, $value, $name) = split /\s+|$/; print "$day $value $name\n"; $m[$day]->{'max'} < $value ? ($m[$day]->{'max'} = $value, $m[$day]->{'bytes'} += $value, ++$m[$day]->{'files'}):( $m[$day]->{'bytes'} += $value, ++$m[$day]->{'files'}) ; $m[$day]->{$name}++; } print "jan\n"; foreach (sort keys %jan){ print "$_ $jan{$_}\n"; } print "feb\n"; foreach (sort keys %feb){ print "$_ $feb{$_}\n"; } __DATA__ 006 175 FILENAME 006 176 good.txt 006 12 bad.txt 007 1856 FILENAME 007 1854 good.txt 008 172 bad.txt 008 177 FILENAME 008 23 good.txt 010 42 bad.txt 032 175 FILENAME 033 2345 FILENAME 032 318 good.txt 033 100 bad.txt 034 175 FILENAME

Replies are listed 'Best First'.
Re^4: Help! Stuck on methods to count file size.
by haimei (Novice) on Dec 05, 2013 at 06:47 UTC

    Dear Master, it's a creative posting again, I feel very much appreciated your guidance. Your code is critical and powerful!

      Great Monker, your previous code also helps me run out as correct result as the updated one does, no mistake fund, you are so helpful to us, thanks again!

      My current question is I want to retrieve bad files and good files from all files, so I did some changes based on your code, it gives me some output that I am not sure is correct or not.