$Bill Luebkert wrote:
Dial, Joe wrote:

Hi,
When I read the first post, I remembered seeing that somewhere before.
Then, I was amazed to see the "this is not what the range operator was
meant to do."
So, I looked for it.  Found it in chapter 6 of the Perl Cookbook. Its
Recipe 6.8.
See this URL: http://www.unix.org.ua/orelly/perl/cookbook/ch06_09.htm

I don't understand exactly why the original posted code doesn't work,
but is remarkably
similar to that recipe.

Maybe Craig will tell us how he resolved his problem (stayed with his
general code or tried something else).

Still putting out fires -- sigh -- but as an FYI, here's the post that opposed using the range operator. I removed the name for obvious reasons and made some grammatical edits for clarity:

*****

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 you 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.

*****

-- Craig


---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0612-0, 03/20/2006
Tested on: 3/20/2006 2:02:07 PM
avast! - copyright (c) 1988-2004 ALWIL Software.
http://www.avast.com




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

Reply via email to