http://qs321.pair.com?node_id=686838


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?