Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Displaying a variable's name and value in a sub

by ciderpunx (Vicar)
on Feb 14, 2011 at 23:16 UTC ( [id://888091]=note: print w/replies, xml ) Need Help??


in reply to Displaying a variable's name and value in a sub

my $a = 'b'; sub show { my $c = shift; print $c . '=' . eval $c; } show('$a');
But you almost certainly shouldn't be doing that, if you really care about the name of your variable pass it as a parameter ie. show('$b',$b);
--
Linux, perl, punk rock, cider: charlieharvey.org.uk.

Log In?
Username:
Password:

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

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

    No recent polls found