in reply to Re^3: Sorting by value??
in thread Sorting by value??
#!/usr/bin/perl my $inFile = "Report.txt"; my $outFile = "SortedReport.txt"; open IN, "< $inFile"; open OUT, ">> $outFile"; my @not_sorted = <IN>; print OUT "|CSED Form|OrderNumber|Date|Total Documents|Total Pages|\n +"; @sorted = sort { lc($a) cmp lc($b) } @not_sorted; # alphabetic +al sort my $count = 1; foreach(@sorted) { $frmType = substr $_, 1, 3; if ($frmType = "M729") { print OUT "$_"; $count ++; } else { print OUT "There were $count Monthly 729 runs\n"; } } foreach(@sorted) { $frmType = substr $_, 1, 3; if ($frmType = "M737") { print OUT "$_"; $count ++; } else { print OUT "there were $count Monthly 737 runs\n"; } } $count = 0; foreach(@sorted) { $frmType = substr $_, 1, 3; if ($frmType = "Q569") { print OUT "$_"; $count ++; } else { print OUT "there were $count Quarterly 569 runs\n"; } } close OUT; close IN;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Sorting by value??
by ahmad (Hermit) on Jun 16, 2010 at 01:07 UTC | |
|
Re^5: Sorting by value??
by graff (Chancellor) on Jun 16, 2010 at 05:16 UTC | |
|
Re^5: Sorting by value??
by kennethk (Abbot) on Jun 16, 2010 at 14:05 UTC | |
by Homerhrdz (Initiate) on Jun 16, 2010 at 16:06 UTC | |
by kennethk (Abbot) on Jun 16, 2010 at 17:29 UTC | |
by Homerhrdz (Initiate) on Jun 17, 2010 at 19:24 UTC |