in reply to Re: Re: Code critique XS function for extracting a blessed regex's pattern.
in thread Code critique XS function for extracting a blessed regex's pattern.
My question is this: given an arbitrary blessed scalar ref, how does one efficiently determine if the object is in fact a regex?
Once you bless a Regexp into another class it isn't a Regexp anymore... try:
<update>As demerphq kindly pointed out I lied :-) Can you spot the silly mistake in the "demonstration" below :-)</update>
my $bqr=bless qr/^blessed$/,"Foo"; print "no match for $bqr\n" unless "normal" =~ m/$bqr/;
:-)
I guess you could subclass it (although this is something I've never tried) - in which case
UNIVERSAL::isa($qr, 'Regexp')
would be the right solution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Code critique XS function for extracting a blessed regex's pattern.
by demerphq (Chancellor) on Feb 06, 2003 at 01:31 UTC | |
by adrianh (Chancellor) on Feb 06, 2003 at 02:06 UTC |