My program requirs to read an input file with 3 columns(month dates, fileSize, fileName)in 3 steps: Here I only give 2 months dates in Julian order for simplifying the process.

1. count the total number of files loaded in each month.
2. count the total file size for each month.
3. count the largest file size in each month.

I do need help to correct my code; when I run it, it doesn't go to output file, and the output is not in individual month but in whol months. Really much appreciated for any help!

Here is my code:
#!/usr/bin/perl require strict; #require warning; #require Date::Manip; require Data::Dumper; require File::Find; require File::stat; #require sort 'stable'; my $filin = '/root/scripts/newsort.in'; my $fleot = '/root/scripts/results/sizeinfo.out'; open my $fh, $filin || die $!; open my $fot, ">$fleot" || die $!; ##Define month lengths @Janlen = ( '006', '007', '008', '009', '010', '011', '012', '013', '0 +14', '015', '016', '017', '018', '019', '020', '021', '022', '023', ' +024', '025', '026', '027', '028', '029', '030', '031' ); @Feblen = ( '032', '033', '034', '035', '036', '037', '038', '039', '0 +40', '041', '042', '043', '044', '045', '046', '047', '048', '049', ' +050', '051', '052', '053', '054', '055', '056', '057', '058', '059' ) +; #Define month hash %mthlens = (@Janlen, @Feblen); my @julens = %mthlens; my $julias = @julens; my $Janlias = @Janlen; my $Feblias = @Feblen; my $Marlias = @Marlen; while (%mthlens=<$fh>){ chomp; my %lengths = map { $_ => length $_ } %mthlens; while ( my ($Janlen,$length,$filename) = each %lengths) { @s = sort { $length{$b} <=> $length{$a}} keys %length; print join("\t", $Janlen, $length, $filename ), "\n"; } }

In reply to count file size by haimei

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.