in reply to Extract potentially quoted words
I usually treat or as lower precedence than anything -- I use it almost exclusively as do_something() or die "Help!" After going through the perlop and perlsyn man pages, I think I see now: the ors are part of the expression that follows the while modifier, not part of the full expression.push @elements, $1 while /\G\s*"(.*?)"/gc || /\G\s*'(.*?)'/gc || /\G\s*(\S+)/gc;
Sooo.... In this case, the || works like the or. You could make an "or die" type of thing by parenthesizing the while expression:
Although this is stupid since the while will return a false value at some point (you hope!), so you'll always die. But if you changed it to an and, you could detect if the loop never executed. (Hmmm... Potentially useful trick.)push @elements, $1 while (/\G\s*"(.*?)"/gc or /\G\s*'(.*?)'/gc or /\G\s*(\S+)/gc) or die "Argh";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Extract potentially quoted words
by tye (Sage) on Jun 07, 2001 at 00:25 UTC | |
by merlyn (Sage) on Jun 07, 2001 at 02:30 UTC | |
by tye (Sage) on Jun 07, 2001 at 02:53 UTC | |
by merlyn (Sage) on Jun 07, 2001 at 02:55 UTC | |
by tye (Sage) on Jun 07, 2001 at 02:56 UTC | |
| |
by VSarkiss (Monsignor) on Jun 07, 2001 at 04:11 UTC | |
by merlyn (Sage) on Jun 07, 2001 at 17:23 UTC | |
by VSarkiss (Monsignor) on Jun 07, 2001 at 01:24 UTC |