#!/usr/bin/perl my $inFile = "Report.txt"; my $outFile = "SortedReport.txt"; open IN, "< $inFile"; open OUT, ">> $outFile"; my @not_sorted = ; print OUT "|CSED Form|OrderNumber|Date|Total Documents|Total Pages|\n"; @sorted = sort { lc($a) cmp lc($b) } @not_sorted; # alphabetical 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;