At 03:36 PM 3/16/2006 -0500, Craig Cardimon wrote:
>I need to read a large text file line by line until a certain tag is
>found, say <TAG>. This tag will exist on a line by itself. Then I need
>read in all subsequent lines, appending them to each other, until the 
>ending tag </TAG> is found, again on a line by itself.

That's not how the range operator was meant to be used.  Its left argument
must be something that can be incremented until it reaches the value of the
right argument.  What u need is a search loop.

$which = 0;
foreach $line (@lines) {
        $state = 1 and next if substr $line, 0, length "<TAG>" eq "<TAG>";
        $state = 0 and ++$which if substr $line, 0, length "</TAG>" eq "</TAG>";
        $matches[$which] .= $line if $state == 1;
}

That will make each element of @matches a string that contains everything
within one tag.





--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to