Regular Expression Annoyance

Jan Henning Thorsen jhthorsen at cpan.org
Sun Jun 13 08:00:49 PDT 2010


Oh. Of course not :/

I think it's a bit weird (inconsistent?) that you need to localize
some variables, while some others get "magically" localized... It is
kind of good though, since depending on $1 to survive through someone
else subroutine could potentially cause bugs later on.

I wonder though if you could predefine &Test::Builder::eval or
&Test::Builder::ok to snatch the variables... ;)

___
.jht

On Sun, Jun 13, 2010 at 4:22 PM, Tom Hukins <tom at eborcom.com> wrote:
> On Sat, Jun 12, 2010 at 06:49:25PM +0200, Jan Henning Thorsen wrote:
>> Can't you just store the value of $1? Like:
>>
>>  my $s;
>>  $mech->content_unlike( ($s) = qr/Error: ([^>]+)/, 'No error message' );
>>  diag $s if $s;
>
> No, you can't:
> perl -e 'use Test::More "no_plan"; like( "X", ($x) = qr/(X)/ ); diag $X'
>
> Tom
> _______________________________________________
> MiltonKeynes-pm mailing list
> MiltonKeynes-pm at pm.org
> http://mail.pm.org/mailman/listinfo/miltonkeynes-pm
>


More information about the MiltonKeynes-pm mailing list