Re: Flip-flop operator help
On Fri, 14 Jul 2006 12:00:08 -0700, you wrote: >I have something like this: > >while () >{ > if (// .. /<\/TAG>/) > { > # process line > } >} > >I got this from http://www.perl.com/pub/a/2004/06/18/variables.html. > >My special wrinkle is, I want to process certain sections of a file, but >only if that section passes certain criteria. > >I want to be able to begin processing lines, but I want to be able to >turn processing off and jump to the next should the script >encounter a line containing, say, the tag . There's no magic way to "reset" the range operator. You could add some sort of flag, such as this (untested): my $skip; while () { if (my $tags = // .. /<\/TAG>/) { $skip = 0 if $tags == 1; # reset flag upon seeing $skip = 1 if //; next if $skip; # process line } } Read the description in perlop for further details. You could also not use the range operator at all; I'll leave the code for that to you. -- Eric Amick Columbia, MD ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Flip-flop operator help
Craig Cardimon wrote: > I have something like this: > > while () > { >if (// .. /<\/TAG>/) >{ ># process line >} > } > > I got this from http://www.perl.com/pub/a/2004/06/18/variables.html. > > My special wrinkle is, I want to process certain sections of > a file, but only if that section passes certain criteria. > > I want to be able to begin processing lines, but I want to be > able to turn processing off and jump to the next should > the script encounter a line containing, say, the tag . What kind of file are we talking about? XML? Can you give us a representative sample? The more you know about the input, the better the choices you can make w.r.t. parsing. - Mark. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Flip-flop operator help
I have something like this: while () { if (// .. /<\/TAG>/) { # process line } } I got this from http://www.perl.com/pub/a/2004/06/18/variables.html. My special wrinkle is, I want to process certain sections of a file, but only if that section passes certain criteria. I want to be able to begin processing lines, but I want to be able to turn processing off and jump to the next should the script encounter a line containing, say, the tag . Anyone know how I might try to accomplish this? Craig ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs