rovf has asked for the wisdom of the Perl Monks concerning the following question:
In my time of PL/1 programming, I liked the PUT DATA statement during debugging: It outputs the name of a variable, together with its value:
outputsx=5; y=7; PUT DATA (x,y);
I wonder whether something similar can be implemented in Perl. Of course the naive approachx=5 y=7
fails if $expr contains my variables from the calling context. I guess a useful implementation would have been to interfere somehow with the compiler (in a similar way the debugger is behaving). Could someone give me some pointer on how this could be implemented? Or maybe is there already some module on CPAN which I could use?use Data::Dumper; sub show { local $Data::Dumper::Terse=1; local $SHOW::expr=shift; local $SHOW::val=eval { $expr }; $SHOW::expr . ($@ ? " throws exception: $@" : ('='.Dumper($SHOW::expr))); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PL/1's PUT DATA in Perl - is this possible?
by BrowserUk (Patriarch) on Nov 07, 2008 at 09:59 UTC | |
by Fletch (Bishop) on Nov 07, 2008 at 14:09 UTC | |
by ikegami (Patriarch) on Nov 07, 2008 at 19:05 UTC | |
by djp (Hermit) on Nov 13, 2008 at 01:13 UTC | |
|
Re: PL/1's PUT DATA in Perl - is this possible?
by ikegami (Patriarch) on Nov 07, 2008 at 09:19 UTC | |
by rovf (Priest) on Nov 07, 2008 at 10:53 UTC | |
by mje (Curate) on Nov 07, 2008 at 11:38 UTC | |
|
Re: PL/1's PUT DATA in Perl - is this possible?
by Anonymous Monk on Nov 07, 2008 at 09:21 UTC |