Say I've got some code like this:
$class = 'Temp';
$re = qr/test/io;
my $regex = bless $re, $class;
After that regular expression is blessed, how do I know that it's a regular expression? I'm writing an in-house utility to dump perl objects and references to XML for transfer between some systems.

If I do '<kbd>ref( $re )</kbd>', I get 'Regexp', as I would expect, but when I do '<kbd>ref( $regex )</kbd>', I of course get 'Temp', and when I do '<kbd>scalar( $regex )</kbd>', rather then getting something useful like 'Temp=Regexp(?-ixsm:test)' like I might expect, I get something like 'Temp=SCALAR(0x00000)'. At this point, I have no way of knowing if that's a regular expression or a scalar ref or exactly what, and I thus can't dump it accurately.

Anyone have any clue how to get this information on blessed regular expressions?

For what it's worth, I checked Data::Dumper's output. It gives me something this:

$VAR1 = bless( do{\(my $o = undef)}, 'Temp' );

In reply to Dumping Compiled Regular Expressions by Hrunting

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.