Dear friends! Please consult me! How I must change the code ,so that "Raport page" prints on the begining of file,not in the end? Code reads the lines,count $env and $page and print those to the report page...
Thank you, VItali Pokrovski ------------------------------ Here is input file: 10Arve nr 1 20 0 30 0 90_ _ A01 10Arve nr 2 20 0 30 0 90__ A02 ----------------------------- while (<STDIN>) { # Read line by line chomp; if (substr($_,0,2) eq "10") { s/10/\x0c10/; } if (substr($_,0,1) ne " ") { $pos = substr($_,0,1)} else { substr ($_,0,1) = $pos; } if (substr($_,0,5) eq "90_ _"){ ++$env} if (substr($_,0,2) eq "A0"){ ++$page} print "$_\n"; } print "\x0c10 RAPORT PAGE\n"; print "10"; print "#" x 74; print "\n"; print "10#Total is: $page pages and $env envelopes\n"; print "10#\n" x 10; print "10"; print "#" x 74; # }; __EOF__ --------------------------------------- Now output file look like this: 10Arve nr 1 20 20 30 30 90_ _ A01 10Arve nr 2 20 20 30 30 90__ A02 10 RAPORT 10########################################################################## 10#Total is: 2 pages and 1 envelopes 10# 10# 10# 10# 10# 10# 10# 10# 10# 10# 10########################################################################## ----- Original Message ----- From: "Tor Hildrum" <[EMAIL PROTECTED]> To: "Perl" <[EMAIL PROTECTED]>; "Steven M. Klass" <[EMAIL PROTECTED]> Sent: Thursday, February 28, 2002 3:01 PM Subject: Re: Sorting a hash table - Advanced;) > On 27/2/02 17:33, "Steven M. Klass" <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > > ok here is the fundamental code > > > > print "\n\n**Summary**\n"; > > foreach my $key (keys %runset){ > > printf ( "%-20s %-20s\n",$key, $runset{$key}); > > } > > > > Now I want to sort this hash for example > > print "\n\n**Summary**\n"; > > foreach my $key (keys %runset){ > > print "Name $runset{foo}" > > # .. other specific keys > > printf ( "%-20s %-20s\n",$key, $runset{$key}); > > } > > > > The question is how can I sort the remaining keys that I haven't already > > printed before. > > > > Basically I want to format this so certain keys get printed in a certain > > order, but there may be some remaining keys that I want printed that I really > > don't care about. (a "catch-all" if you will) > > > > Thanks > > print "\n\n**Summary**\n"; > foreach my $key (keys %runset){ > print "Name $runset{foo}" > # .. other specific keys > foreach $key (sort keys %runset) { ## sort the remaining in ASCII order. > printf ( "%-20s %-20s\n",$key, $runset{$key}); > } > > Something like that? > > -- > T. > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]