Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: RFC: Data::Dumper::Simple

by dfaure (Chaplain)
on Jul 31, 2004 at 23:50 UTC ( [id://378998]=note: print w/replies, xml ) Need Help??


in reply to RFC: Data::Dumper::Simple

And what about this:

#!perl -w use strict; my $scalar = 'dfaure'; my @array = ( 'Data', 'Dumper', 'Simple', 'Rocks!' ); my %hash = ( 'it' => 'does', 'I' => 'hope', 'at' => 'least' ); sub MyDumper { my @values; for (@values = @_) { s/^([%@])/\\$1/; $_ .= ','; } my @names; for (@names = @_) { s/^[%@]/*/; s/^\$//; } return eval "use Data::Dumper;Data::Dumper->Dump([@values],[qw/@na +mes/])"; } print MyDumper(qw/$scalar @array %hash/);

____
HTH, Dominique
My two favorites:
If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
Bien faire, et le faire savoir...

Replies are listed 'Best First'.
Re^2: RFC: Data::Dumper::Simple
by Ovid (Cardinal) on Aug 01, 2004 at 00:27 UTC

    That fails because eval is limited to the current lexical scope, hence Aristotle's suggestion to use PadWalker.

    do { my @array = ( qw/foo bar/ ); print MyDumper(qw/@array/); }; sub MyDumper { my @values; for (@values = @_) { s/^([%@])/\\$1/; $_ .= ','; } my @names; for (@names = @_) { s/^[%@]/*/; s/^\$//; } + return eval "use Data::Dumper;Data::Dumper->Dump([@values],[qw/@na +mes/])"; }

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://378998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-19 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found