Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 pondering the Monastery: (2)
As of 2024-06-14 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.