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

Re: Missing ref() return possibility?

by rhesa (Vicar)
on May 16, 2008 at 01:42 UTC ( #686838=note: print w/replies, xml ) Need Help??

in reply to Missing ref() return possibility?

The types you list are the basics. All other cases are covered by "If the referenced object has been blessed into a package, then that package name is returned instead."

For regular expressions, this is demonstrated by:

use Scalar::Util qw/blessed/; $q=qr//; print ref($q); print blessed($q); __END__ Regexp Regexp

Replies are listed 'Best First'.
Re^2: Missing ref() return possibility?
by kyle (Abbot) on May 16, 2008 at 21:51 UTC

    What your code implies but isn't quite explicit about is that qr() actually gives back a blessed reference to a scalar.

    use Scalar::Util qw/blessed reftype/; my $q = qr//; print 'ref: ', ref($q), "\n"; print 'blessed: ', blessed($q), "\n"; print 'reftype: ', reftype($q), "\n"; __END__ ref: Regexp blessed: Regexp reftype: SCALAR

    There's some more about this in How can I tell if an object is based on a regex?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2021-10-22 10:44 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (85 votes). Check out past polls.