Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^4: How do I determine if a variable contains a type glob?

by ikegami (Patriarch)
on Dec 05, 2016 at 07:18 UTC ( [id://1177199]=note: print w/replies, xml ) Need Help??


in reply to Re^3: How do I determine if a variable contains a type glob?
in thread How do I determine if a variable contains a type glob?

And what do you think *fh is.

A glob, what you should have used instead of \*fh.

You don't (*CAN'T*) bless a var; only a reference to one!

Actually, you have that backwards. I've never seen a blessed reference. You have to pass a reference to bless, but it's the var that gets blessed. Otherwise, the following would fail:

sub foo { CORE::say "ok" } my %h; my $ref1 = \%h; my $ref2 = \%h; bless($ref1); $ref2->foo();

How can "the reference be blessed",

I said ref would fail if the glob is blessed.

$ perl -MScalar::Util=reftype -e' CORE::say ref(\*FOO); CORE::say reftype(\*FOO); bless(\*FOO); CORE::say ref(\*FOO); CORE::say reftype(\*FOO); ' GLOB GLOB main GLOB

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found