develooper Front page | perl.perl5.porters | Postings from January 2012

Re: [perl #108780] overload::StrVal and qr//

Thread Previous | Thread Next
From:
demerphq
Date:
January 25, 2012 08:45
Subject:
Re: [perl #108780] overload::StrVal and qr//
Message ID:
CANgJU+Wr=_2FBSHqah2w4jTYV5oEB3-=tpq1tcwg3=+Px06zew@mail.gmail.com
On 25 January 2012 17:20, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
> * demerphq <demerphq@gmail.com> [2012-01-25T10:51:14]
>> On 24 January 2012 03:03, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>> > * Father Chrysostomos <sprout@cpan.org> [2012-01-22T17:50:54]
>> >> Is the overloading pragma new enough to change without breaking things?
>> >
>> > Making "do { no overloading; qr{foo} }" return a Regexp=REGEXP(..) string is a
>> > bug fix.
>>
>> Just curious, but is that a ruling-from-on-high, or is it a fact?
>>
>> I really do wonder if no overloading in earlier perls would have
>> behaved as you describe.
>>
>> This is of course totally orthagonal to this being a bug.
>
> In 5.10.1, overloading.pm existed and Regexp were still SCALAR.  "no
> overloading" did not get you the StrVal.  This, I say, was a bug, too.

Depends what you think about the following:

$ cat testit.pl
use strict;
use warnings;
use Test::More tests=>4;
no overloading;
my $qr1=qr/(foo)/;
my $qr2=qr/(boo)/;
my $qr3=qr/(loo)/;
ok( (("foo" =~ $qr1) && $1 && ($1 eq "foo")), "Raw regex");
ok( (("boo" =~ /$qr2/) && $1 && ($1 eq "boo")), "Raw regex redux");
ok( (("xlooy"=~/x${qr3}y/) && $1 && ($1 eq "loo")),"Embedded regex");
ok("$qr1"=~/REGEXP/,"Sanity check");

$ ./perl -Ilib testit.pl
1..4
ok 1 - Raw regex
ok 2 - Raw regex redux
not ok 3 - Embedded regex
#   Failed test 'Embedded regex'
#   at testit.pl line 10.
ok 4 - Sanity check
# Looks like you failed 1 test of 4.

Which I think I might call a bug.

cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About