in reply to accessing backreferences

Don't access the backreferences from there... save them in a list as a result of the match. (Your way is dangerous if the match fails, by the way.)
use strict; if (my @matches = /(f.o)(b.r)(b.z)/) { print "Match # $_ is $matches[$_-1]\n" for 1..@matches; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: accessing backreferences
by YaRness (Initiate) on Mar 15, 2001 at 01:32 UTC
    it actually IS like that, i just scratched up that example for... well, for example. i always use some kind of if statement to check a match before hitting backreferences.