develooper Front page | perl.beginners | Postings from February 2002

RE: How to print firstly Raport page ,and after data from input file

Thread Previous
From:
Mark Anderson
Date:
February 28, 2002 09:35
Subject:
RE: How to print firstly Raport page ,and after data from input file
Message ID:
POENIDJMGJHIICHDIHNPCEBECGAA.manderson@gcamail.com
I'll help what I can.  You need to store the input and not print it out
until after you've printed out your raport.  I'm not sure what you are
doing, so I haven't tried to fix anything except the printing of the report.
If this code is going to be in use for a while, it would be good for you to
add more comments, and use a better style for indenting.

				/\/\ark


my @inputarray = ();
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}

# Save the input to an array and print it out later
#print "$_\n";
push @inputarray,"$_\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;
print "\n";

#print the input array
foreach (@inputarray) {print}
__EOF__







-----Original Message-----
From: Vitali [mailto:vipo@hot.ee]
Sent: Thursday, February 28, 2002 6:00 AM
To: perl-ntadmins@topica.com; beginners@perl.org
Subject: How to print firstly Raport page ,and after data from input
file


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
-----------------------------

my @inputarray = ();
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}

# Save the input to an array and print it out later
#print "$_\n";
push @inputarray,"$_\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;   # };

#print the input array
foreach (@inputarray) {print};
__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##########################################################################

----------------------------------------------------------------------------


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About