Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am opening a file that is new-line delimited , I am doing a while loop over the file handle. I am trying append each line to a variable until i've passed over 20 lines. below is my code.
any help is appreciatedopen(FILE, $listfile); while(my $user = <FILE>) { $user =~ s/(\r|\n)//; # windows compatibility $userout .="$user,"; $lcount++; if ($lcount == 20) { print PIPE "$userout"; $lcount=0; } next if !$user; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: while loop over filehandle
by BrowserUk (Patriarch) on Sep 23, 2002 at 05:28 UTC | |
Re: while loop over filehandle
by spartacus9 (Beadle) on Sep 23, 2002 at 05:09 UTC | |
by diotalevi (Canon) on Sep 23, 2002 at 13:50 UTC | |
Re: while loop over filehandle
by Aristotle (Chancellor) on Sep 23, 2002 at 07:50 UTC | |
Re: while loop over filehandle
by kabel (Chaplain) on Sep 23, 2002 at 08:42 UTC | |
Re: while loop over filehandle
by Flexx (Pilgrim) on Sep 23, 2002 at 14:08 UTC |
Back to
Seekers of Perl Wisdom