Re: [Perl-unix-users] Search for a line and print the next 5 from a file

2005-01-31 Thread $Bill Luebkert
Craig Sharp wrote: > Hi all, > > I know this is simple but I have having a brain lock today. > > I have a file in which I need to find a particular line. Once I find the > line, I need to print the next 5 lines and quit. > > The following gets me to the line but I am stuck from there. > > #!

Re: [Perl-unix-users] Search for a line and print the next 5 from a file

2005-01-31 Thread Martin Moss
Hi Craig, You need to use a counter. my $count =0; $count++; You will need to also check the counter on each loop iteration using 'if' 'else' and 'last' to exit the loop.. my $count=0; if ($count > 4) { last } else { $count++; } there's several ways to do this Here is one.. Incidentally, un

Re: [Perl-unix-users] Search for a line and print the next 5 from a file

2005-01-31 Thread Craig Sharp
escription:/){ for (my $x = 0; $x < 5; $x++) { print readline(INFILE) . "\n"; } last; } } close (INFILE); -Tim "Craig Sharp" <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 01/31/2005 09:57 AM To cc Subject [Perl-unix-use

[Perl-unix-users] Search for a line and print the next 5 from a file

2005-01-31 Thread Craig Sharp
Hi all, I know this is simple but I have having a brain lock today. I have a file in which I need to find a particular line. Once I find the line, I need to print the next 5 lines and quit. The following gets me to the line but I am stuck from there. #!/usr/bin/perl -w open (INFILE,"filemon2