in reply to get name of lexical variable

If you need that information, you are breaking a number of encapsulation rules that are really bad to break.

Could you explain why you want to do this in the first place?

Replies are listed 'Best First'.
Re^2: get name of lexical variable
by rovf (Priest) on Jul 13, 2009 at 07:09 UTC

    One could write a nice subroutine useful in debugging, whic when called in the following way:

    my $aLex=25; print(display($aLex),"\n");
    would print
    $aLex == 25

    -- 
    Ronald Fischer <ynnor@mm.st>

        I'm not so happy with either one. Data::Dumper::Simple uses a source filter, and source filtering has already bitten me more than once. Data::Dumper::Names uses undocumented features in Perl which doesn't make it trustworthy either...

        -- 
        Ronald Fischer <ynnor@mm.st>

      I agree that there are uses for a subroutine that can return such names as requested, but usually when people ask for something like this, its a sign of a more mundane problem solved in the wrong way.

        Encapsulation rules? Which ones did s/he break? Looks like a solid debug example to me.