Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: RFC: Data::Dumper::Simple

by dfaure (Chaplain)
on Jul 31, 2004 at 23:50 UTC ( #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
Node Status?
node history
Node Type: note [id://378998]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2021-04-21 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?