in reply to Re: How to view contents of a blessed Regular Expression?
in thread How to view contents of a blessed Regular Expression?

Hmmm, doesn't work for me using ActiveState Perl 5.6.1. I wonder if it makes a difference that I'm blessing it in the context of an eval{} function like so:
eval { bless qr/$pattern/, ref($class) || $class };
I'm finding this all very confusing and I should probably just forget about such a minor thing.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop";
$nysus = $PM . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
(tye)Re: How to view contents of a blessed Regular Expression?
by tye (Sage) on Jul 16, 2001 at 19:42 UTC

    qr// gives you a reference to a scalar that is already blessed into the Regexp package. So you are reblessing it which stops Regexp methods/overloads from working on it after that point. Stringification is a Regexp overload and so no longer works. If you want stringification again, then you'd need to provide such a overload via your AltRegex package.

            - tye (but my friends call me "Tye")
      But if you inherit from Regexp, wouldn't the overload be inherited as well? i.e. this works:

      use strict; $^W++; package A; use overload '""' => sub { overload::StrVal(shift) . 'xx' }; package B; @B::ISA = 'A'; package main; my $a = bless \(my $aa = 'abc'), 'A'; print "$a\n"; bless $a, 'B'; # re-bless print "$a\n";
        Well, as I thought, this is beyond my grasp right now. I think I'm getting too bogged down in the details. I'll bookmark this node and come back to it in a couple months.

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop";
        $nysus = $PM . $MCF;
        Click here if you love Perl Monks