Tim, Perfect! Thanks for the help.
Craig >>> <[EMAIL PROTECTED]> 01/31/05 11:15AM >>> Try this... #!/usr/bin/perl -w open (INFILE, "< filemon2005012970.out") || die("Cannot open file: $!"); while (<INFILE>) { chomp; if (/\/dev\/hdisk18 description:/){ 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 <Perl-Unix-Users@listserv.ActiveState.com> cc Subject [Perl-unix-users] Search for a line and print the next 5 from a file 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,"filemon2005012970.out") || die("Cannot open file: $!"); @LINES = <INFILE>; foreach (@LINES){ chomp; if (/\/dev\/hdisk18 description:/){ print "$_\n"; } } Thanks, Craig _______________________________________________ Perl-Unix-Users mailing list Perl-Unix-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs This message (including any attachments) may contain confidential or privileged information, the use and disclosure of which is legally restricted. If you have received this message in error, please notify the sender by reply message, do not otherwise distribute it, and delete this message, with all of its contents, from your files. _______________________________________________ Perl-Unix-Users mailing list Perl-Unix-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs