Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
From what I know you are almost correct. adrianh has the problem but missed* in the turgid docs of perldoc:overload the implication of overload::StrVal which will return the pattern you specify. If that changed an endless chunk of code would break. Including Data::Dumper. You, or I or someone should post a documentation patch to make it permanent however.

Heres a more rigourous definition of a is_blessed test.

$is_blessed = defined($x) && ref($x) && overload::StrVal($x) =~ /=/;
Incidentally for this check its faster but less idiomatic to say
$is_blessd=defined($x) && ref($x) && (index(overload::StrVal($x),'=')> +=0);
BTW, only if you choose to consider qr// constructs to be blessed then this test is fine. If you dont then you need something like
$is_blessd=defined($x) && ref($x) && (index(overload::StrVal($x),'=')> +=0) && overload::StrVal($x)!~/^Regexp=SCALAR/;
PS: Im hoping that its obvious that you have to use overload; for all of this.


update:* I didnt mean to imply that he was wrong about the Scalar::Util approach. However it is an extra module and the code I mention should be fine without it. Although it is a lot faster to use than all of the above.

--- demerphq
my friends call me, usually because I'm late....

In reply to Re: stringified references by demerphq
in thread stringified references by rir

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2022-11-27 16:26 GMT
Find Nodes?
    Voting Booth?