astroboy has asked for the wisdom of the Perl Monks concerning the following question:
Consider the following code:
use Data::Dumper; my $sub = sub { my $filename = shift; return '/tmp/' . $filename; }; print Dumper($sub);
Executing it returns
$VAR1 = sub { "DUMMY" };
which is kinda what I expect, since as the Data::Dumper documentation points out, "Data::Dumper cheats with CODE references. If a code reference is encountered in the structure being processed (and if you haven't set the Deparse flag), an anonymous subroutine that contains the string '"DUMMY"' will be inserted in its place, and a warning will be printed if Purity is set."
So is there any other way, to see a string representation of a code ref? The reason I ask is that I'm generating arrays of code refs on the fly, and it would help my debugging if I could see what was generated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is it possible to view a string representaion of a code ref?
by shmem (Chancellor) on May 13, 2009 at 23:57 UTC | |
by targetsmart (Curate) on May 14, 2009 at 05:58 UTC | |
by ysth (Canon) on May 14, 2009 at 06:40 UTC | |
by targetsmart (Curate) on May 14, 2009 at 11:35 UTC | |
by Anonymous Monk on May 14, 2009 at 11:59 UTC | |
| |
by astroboy (Chaplain) on May 14, 2009 at 00:22 UTC |