Sharky_The_Dog has asked for the wisdom of the Perl Monks concerning the following question:
<TR> <p> FOO BAR </p> <a href=www.yahoo.com>yahoo</a> </TR>This format follows throughout the file, and only the line that says FOO BAR is searchable, but I want to return that line and the line after (and hypothetically, the line after that, and after that and so on...) when a search is confirmed. Here's my problem: I can find the line with the "hit" just fine, but for the life of me, I can't make perl notice the </TR> tag. here's a sample of the code I am trying to make work:
my $trString = "</TR>";
while ( <DATAFILE> )
{
chomp;
if ( /$content/ )
{
$searchString .= $_;
until ( /$trString/ )
{
chomp;
$searchString .= $_;
}
print "<TR>$searchString";
}
}
I have tried numerous things, messing with flags, etc, and I couldn't get it to work.. can someone help?
Worth noting: I'm a newbie at perl and have programmed in java/c/basic my entire life, so please be patient if this looks like garbage to you. Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File/String search...
by maverick (Curate) on Sep 07, 2000 at 01:31 UTC | |
|
Re: File/String search...
by jreades (Friar) on Sep 07, 2000 at 03:47 UTC | |
by tye (Sage) on Sep 07, 2000 at 19:22 UTC | |
|
Re: File/String search...
by Adam (Vicar) on Sep 07, 2000 at 01:25 UTC | |
by jcwren (Prior) on Sep 07, 2000 at 01:29 UTC | |
|
Re: File/String search...
by Fastolfe (Vicar) on Sep 07, 2000 at 01:50 UTC |