sorry. still in dark. what exactly does '/START_KEYWORD/.../END_KEYWORD/' mean? I see a regex -> /START_KEYWORD/ an ellipsis -> ... and a regex -> /END_KEYWORD/ you are saying the whole thing means something, but I don't understand what. you say 'the elipsis returns false' what does that mean? what is it able to match? and why?
On Saturday, March 30, 2002, at 10:23 AM, Jenda Krynicky wrote: > From: bob ackerman <[EMAIL PROTECTED]> > >> i don't understand your answer. how will that match anything? >> the first line matches the whole block ok, but then the match is >> dropped by the '!' phrases since they are in the text. also, where is >> documented the ellipsis in a grep? also, using two regexes on either >> side of the ellipsis? > > I am not using two regexps on one site of the ellipsis. > > If I add braces into the code you'll get this: > > grep { ( /START_KEYWORD/.../END_KEYWORD/ ) > and ( !/START_KEYWORD/ ) > and ( !/END_KEYWORD/} ) > > Let's "interpret" the code in mind. > We have > > @data = ( "some header", > "some more unimportant stuff", > "START_KEYWORD", > "here's the text we want", > "and here some more", > "END_KEYWORD", > "and again some boring stuff" > ); > > > @filtered = grep { ( /START_KEYWORD/.../END_KEYWORD/ ) > and ( !/START_KEYWORD/ ) > and ( !/END_KEYWORD/ ) } @data; > > So first Perl processes the first item ("some header") : the elipsis > returns false, the other conditions are not even tried, item is not > accepted. > > Second item ("some more unimportant stuff") : again the same, > ellipsis is false => item is not accepted. > > Third item ("START_KEYWORD") : ellipsis matches, returns true > and switches to the second state (that is it'll return true until it > matches the END_KEYWORD), but the second condition returns > false so the item is not accepted. > > Fourth item ("here's the text we want") : the item doesn't match the > "ending condition" of the elipsis so the ellipsis still returns true, the > other two conditions also return true (keep in mind that the regexps > are negated!) => item is accepted. > > Fifth item : same as fourth > > Sixth item ("END_KEYWORD") : the "end condition" of the ellipsis > matches, ellipis returns true but switches to the first (false) state, > the second condition returns true, but the third condition returns > false => item is not accepted. > > .... > > Jenda > > > =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== > There is a reason for living. There must be. I've seen it somewhere. > It's just that in the mess on my table ... and in my brain > I can't find it. > --- me > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >