in reply to Re^2: here-docs vs quote operators
in thread here-docs vs quote operators

How about this?

use strict; use Data::Dumper; sub print_code { my ($sub) = @_; my $d = Data::Dumper->new( [$sub] ); $d->Deparse(1); print $d->Dump(); }; print_code(sub{ print 'This is a coderef' });

Replies are listed 'Best First'.
Re^4: here-docs vs quote operators
by Anonymous Monk on Feb 16, 2006 at 22:02 UTC
    Hmm... doesn't work on my system. :-( I get: Can't locate object method "Deparse" via package "Data::Dumper" (perhaps you forgot to load "Data::Dumper"?) at - line 6.

    What version of perl and/or Data::Dumper do I need to pull off that trick? :-(

      It works for me with Data::Dumper 2.121, on v5.8.5 built for MSWin32-x86-multi-thread. There is no other version of Data::Dumper on CPAN and I think that all the 5.8 Perls come with this feature.