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

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";
  • Comment on Re: (tye)Re: How to view contents of a blessed Regular Expression?
  • Download Code

Replies are listed 'Best First'.
Re: Re: (tye)Re: How to view contents of a blessed Regular Expression?
by nysus (Parson) on Jul 16, 2001 at 19:51 UTC
    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

      Regex's stringify overload isn't a regular overload via overload.pm, its a block of code in perl's main stringify routine: sv.c:sv_2pv_flags(). This explicitly checks for a package name of Regex up through perl 5.8.0, so having your new regex class be a subclass of Regex does nothing (except make isa("Regex") checks work. For 5.8.1 and later, the needless package name check is omitted, so reblessed regexes should Just Work.