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

Re: Using format()

Thread Previous
From:
William.Ampeh
Date:
February 26, 2002 06:36
Subject:
Re: Using format()
Message ID:
OFA8E7794E.69B18E7E-ON85256B6C.00501B45@frb.gov

#!/opt/local/bin/perl

$CUR_TIME=`date "+%B-%Y"`;
$TITLE="Annual Report on Car Sales";

select ("STDOUT");

$~ = STDOUT;
for ($i = 1; $i <10; $i++) {

   $color = "Red";
   if ( $i % 2 ) { $color = "Blue"};

   $col1 = "${color}_car_col_1";
   $col2 = "${color}_car_col_2";
   $col3 = "${color}_car_col_3";
   $col4 = "${color}_car_col_4";

   write STDOUT;

   if ( $i % 5 == 0 ) {
      $~ = STDOUT_BLANK;  write STDOUT_BLANK;
      $~ = STDOUT;
   }
}

$~ = STDOUT_BOTTOM; write;

#-----------------------  OUTPUT FORMAT BEGINS HERE -------------------

format STDOUT =
           @<<<<<<<<<<<<<<        @>>>>>>>>>>>>>     @<<<<<<<<<<<<<<<
@|||||||||||||||||||||
$col1, $col2, $col3, $col4

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