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.
>
> #!
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
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
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