John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
and it didn't work. $result was 1, not the contents of $1. I wrote it using ?: instead, and I can think of a few other ways to write it, so I'm not looking for immediate help on this problem.my ($result)= m[pattern(group)] || "default";
What I am wonering is exactly what the issue is, and how to get around it, for my own knowledge. I'm supposing that || forces scalar context on its arguments, and using ()'s around things doesn't help. So how would you get the RE evaluated in list context?
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Did I match or didn't I?
by gbarr (Monk) on Oct 18, 2001 at 00:23 UTC | |
|
Re: Did I match or didn't I? (boo)
by boo_radley (Parson) on Oct 18, 2001 at 00:21 UTC | |
by blakem (Monsignor) on Oct 18, 2001 at 00:33 UTC | |
by John M. Dlugosz (Monsignor) on Oct 18, 2001 at 02:06 UTC | |
|
Re: Did I match or didn't I?
by tadman (Prior) on Oct 18, 2001 at 02:24 UTC | |
by John M. Dlugosz (Monsignor) on Oct 18, 2001 at 19:38 UTC | |
by chipmunk (Parson) on Oct 18, 2001 at 20:17 UTC | |
|
Re: Did I match or didn't I?
by Hofmator (Curate) on Oct 18, 2001 at 12:52 UTC | |
|
Re: Did I match or didn't I?
by suaveant (Parson) on Oct 18, 2001 at 00:12 UTC |