Hrunting has asked for the wisdom of the Perl Monks concerning the following question:
$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' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Dumping Compiled Regular Expressions
by tye (Sage) on Nov 21, 2000 at 02:17 UTC | |
|
Re: Dumping Compiled Regular Expressions
by chromatic (Archbishop) on Nov 21, 2000 at 01:16 UTC | |
by Hrunting (Pilgrim) on Nov 21, 2000 at 01:28 UTC | |
|
Re: Dumping Compiled Regular Expressions
by Fastolfe (Vicar) on Nov 21, 2000 at 01:50 UTC | |
by chromatic (Archbishop) on Nov 21, 2000 at 01:57 UTC | |
by Hrunting (Pilgrim) on Nov 21, 2000 at 02:00 UTC |