in reply to Did I match or didn't I?
my ($result) = m[pattern(group)] or "default";The two OR operators actually behave quite differently, much in the same way that '==' and 'eq' do similar things, but in a different way.
my ($result) = m[pattern(group)]? $1 : "default";Since in this case, you are evaluating the result of the match explicitly, then returning either $1 or the string. The former, using 'or', is probably the best way to handle this, since ?: is a bit confusing to some.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Did I match or didn't I?
by John M. Dlugosz (Monsignor) on Oct 18, 2001 at 19:38 UTC | |
by chipmunk (Parson) on Oct 18, 2001 at 20:17 UTC |