http://www.perlmonks.org?node_id=128339


in reply to Can I get the name of a variable passed to a subroutine?

Well,
I think I'd turn the logic round: call that routine with the name of the variable:
dBug_showArray("@currTime");
and eval() that string in your subroutine.

Hmm, one major flaw of this would be scoping: you'd need to really know that variable there, and that would mean you'd only be able to show global variables there. Maybe something could be done using closures, but since I don't exactly know what they are/look like I could be wrong.

Replies are listed 'Best First'.
Re: Re: Can I get the name of a variable passed to a subroutine?
by IlyaM (Parson) on Nov 30, 2001 at 23:18 UTC
    It almost useless. Unless you use global vars all time (very bad idea) it doesn't work because of scoping.

    --
    Ilya Martynov (http://martynov.org/)