On Thursday 01 July 2004 15:57, John W. Krahn wrote: > > On Thursday 01 July 2004 05:48, [EMAIL PROTECTED] wrote: > > > > I am trying to figure out how to print 8 scalers/elements then \n, > > then 5 more lines of 8 or less for a max total of 40 Here is my > > code: > > > > print FILEOUT "eject 0,0,0 "; > > my $count = `wc -l <$ejectapes`; > > > > if ($count <= 40 ) { > > > > while(<FILE>) { > > chomp $_; > > print FILEOUT "$_ "; # if 1..8 > > #print substr($a,0,7); > > } > > close (FILEOUT); > > } > > This is one way to do it: > > print FILEOUT 'eject 0,0,0'; > until ( eof FILE ) { > for ( 1 .. 8 ) { > chomp( local $_ = <FILE> ); > print FILEOUT " $_"; > last if eof FILE; > } > print "\n"; > }
Oops. I forgot about the maximum of 40 spec: my $count = 40; print FILEOUT 'eject 0,0,0'; until ( eof FILE or not $count ) { for ( 1 .. 8 ) { chomp( local $_ = <FILE> ); print FILEOUT " $_"; last if eof FILE or not --$count; } print "\n"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>