The scope of regex capture variables

In subroutines

An alias to $1 is a reference to $1 always

'foo' =~ /(.*)/;

foo('Do it 5 times please',$1);

sub foo {
    shift() =~ /(\d+)/;
    print shift() x $1;
}

OK, this is a bit contrived but to avoid such problems the rule is either

Next