Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Dumping variables but DRY and simple

by LanX (Canon)
on Mar 27, 2010 at 17:42 UTC ( #831382=note: print w/ replies, xml ) Need Help??


in reply to Re: Dumping variables but DRY and simple
in thread Dumping variables but DRY and simple

Ok this goes somehow in the direction of code generation like Smart::Comments with the difference that you can still safely use it in production code.

But then I would rather prefer to insert an eval-macro solution giving me the opportunity to change details dynamically at central place:

#!/usr/bin/perl my @bla=(0..9); sub dmp_macro { my $var=shift; (my $var2=$var) =~ tr/@%$//d; use Data::Dumper; return "print Data::Dumper->Dump([\\$var],['\*$var2'])" } print dmp_macro('@bla'),"\n"x3; eval (dmp_macro qw/@bla/);

output:

print Data::Dumper->Dump([\@bla],['*bla']) @bla = ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 );

(OK I admit, it's not only lisp-ish, it's even uglier ;-)

Cheers Rolf


Comment on Re^2: Dumping variables but DRY and simple
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (17)
As of 2015-07-30 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls