When you say that you don't recommend the numbered capture globals, do you mean in general or specifically when dealing with MooseX? Do you always use your own variables for regex captures? Why? Not being critical, I just like learning and I'm still firmly an early intermediate Perl programmer (by my own guesstimate).In general. I always store the return value of the matched regex (usually in lexical variables), which eliminates a lot of confusion: you know in what scope the variable storing the captured value is, unlike with the globals, and you can do more regex matching without worrying about overwriting previous values. Also, it's simply unnecessary to do
when you can do$string =~ /$pattern/; my $match_foo = $1; my $match_bar = $2;
The relevant programming patterns I use the most probably look something like like
if (my ($foo, $bar) = $input =~ /$pattern/) {
and
my @matches = grep { condition } map { /(foo)(bar)/ } @data;
In reply to Re^3: a MooseX Q that's driving me up the wall :)
by Anonymous Monk
in thread a MooseX Q that's driving me up the wall :)
by tj_thompson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |