On Wed, 7 Jul 2004, Michele Dondi wrote:
>I have a minor doubt about predefined variables related to pattern
>matching: in particular is it safe to do something like this?
>
> if ( /\{([\w:]+)\}/ ) {
> do_something($`, $', split /:/, $1);
> }
>
>I mean: are $`, $' and $1 those coming from the
>*first* pattern matching in all cases?
You could have determined that on your own with testing. As it stands,
yes they are. I'm a little surprised about $` and $', but that's because
split() doesn't affect them. Had you done:
if ( /\{([\w:]+)\}/ ) {
do_something($`, $', $1 =~ /[^:]*/g);
}
you would get rather unexpected results.
I also advise against using $` and $' and $& if you can avoid them.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
RPI Corporation Secretary % have long ago been overpaid?
http://japhy.perlmonk.org/ %
http://www.perlmonks.org/ % -- Meister Eckhart