Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Re: Identifying if a variable is the product of a qr//

by Juerd (Abbot)
on Apr 25, 2002 at 10:34 UTC ( #161911=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Identifying if a variable is the product of a qr//
in thread Identifying if a variable is the product of a qr//

although thats what I thought at first too, run the code I provided.

Did run it, but didn't notice the scalar ref matching correctly.

Using Devel::Peek, you can clearly see there is something MAGICal going on, maybe it helps...

2;1 juerd@ouranos:~$ cat dm use Devel::Peek; print Dump bless qr/foo/, 'foo'; print Dump bless \my $foo, 'foo'; 2;0 juerd@ouranos:~$ perl dm SV = RV(0x810b404) at 0x80f60ac REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x80f61a8 SV = PVMG(0x8101b30) at 0x80f61a8 REFCNT = 1 FLAGS = (OBJECT,RMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x80fffe0 MG_VIRTUAL = 0x80f4f74 MG_TYPE = 'r' MG_OBJ = 0x8100160 STASH = 0x80fd414 "foo" SV = RV(0x810b404) at 0x80f60ac REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x80fd450 SV = PVMG(0x8101b30) at 0x80fd450 REFCNT = 2 FLAGS = (PADBUSY,PADMY,OBJECT) IV = 0 NV = 0 PV = 0 STASH = 0x80fd414 "foo"

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.


Comment on Re: Re: Re: Identifying if a variable is the product of a qr//
Download Code
Re: Re: Re: Re: Identifying if a variable is the product of a qr//
by Molt (Chaplain) on Apr 25, 2002 at 10:42 UTC

    I guess it's the MG_TYPE='r' line which is indicating it's a magical Regexp, and the magic isn't affected when it's bless'ed.

    A quick look through my copy of perlguts however reveals that.. err.. r isn't listed as a possible value of MG_TYPE.

    Now planning on hitting Inline::CPP a bit more when I get home see if I can magically regexp'ify strings and visa-versa..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://161911]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-07-12 16:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (240 votes), past polls