I'm working with very simple viewer code and here's a working snippet of it. My problem is how to print the next line after the line that includes BLAH. So I want to print lines including BLAH keyword and when BLAH is found the next line after it. The next line carries additional info for the keyword line it's after, and I can't do any changes to original file.

And yes I know, this is quite a simple problem, but for some reason my brains are bit rusty at the moment.:)

#!/usr/bin/perl
# print lines wich include BLAH keyword
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>av</title></head><BODY>\n";
open(HTMLOLD, "/.../.../pohja.html");
@lines=<HTMLOLD>;
close(HTMLOLD);
$count = 0;
foreach $line (@lines) {
    if ($line =~ /BLAH */) {
        print "$line";
        $count++;
    }
    if ($count eq 50){
        last;
    }
}

print "</body>\n";
print "</html>\n";



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to