Jeffrey Kegler has asked for the wisdom of the Perl Monks concerning the following question:
For most practical purposes, this question is totally useless. But I have a CPAN module Test-Weaken, which detects leaks in arbitrary Perl data structures. It needs to traffic in references to as many Perl data objects as possible. For all the Perl data types except one, I can duplicate a reference, as follows:
\@{$array_ref} # ARRAY \%{$hash_ref} # HASH \${$scalar_ref} # SCALAR, REF, LVALUE, VSTRING, Regexp \*{$glob_ref) # GLOB, IO, FILEHANDLE \&{$code_ref} # CODE
My question: how do I dup a FORMAT reference?
You can get a format reference with this syntax: $formatref = *foo{FORMAT}. Formats themselves are deprecated and why you'd want a reference to one I don't know, but my purpose is to allow Test::Weaken to be able to deal with whatever data is thrown at it. That data may come from perverse and/or legacy code.
UPDATED: corrected typos.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to dereference a FORMAT reference?
by morgon (Priest) on Jun 23, 2009 at 23:17 UTC | |
by Jeffrey Kegler (Hermit) on Jun 24, 2009 at 00:52 UTC | |
by tye (Sage) on Jun 24, 2009 at 06:35 UTC | |
by morgon (Priest) on Jun 24, 2009 at 15:32 UTC | |
by Jeffrey Kegler (Hermit) on Jun 24, 2009 at 15:41 UTC |