Debugger question

D

Derek Goto

I was running the perl debugger with arguments "-d -e 1" to test a small
program. When I assigned a value to the variable $foo, I could use it
fine, but when I qualified $bar with my, it remained undefined. Same
with local. Why is this? Does the debugger operate in a different scope
than main? If so, shouldn't I be able to access those values anyway? I
could access the value of $bar from the debugger when it was assigned
within in a script, but I couldn't successfully modify it. What's going
on here?
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was running the perl debugger with arguments "-d -e 1" to test a small
program. When I assigned a value to the variable $foo, I could use it
fine, but when I qualified $bar with my, it remained undefined. Same
with local. Why is this? Does the debugger operate in a different scope
than main? If so, shouldn't I be able to access those values anyway? I
could access the value of $bar from the debugger when it was assigned
within in a script, but I couldn't successfully modify it. What's going
on here?

It's a limitation inherent in the debugger.

Each expression you enter at the debugger prompt is evaluated in its own
scope. When the expression is finished, the scope goes away. Your
assignment to "my $bar" works, but at the end of the scope $bar goes away,
and when you next type "p $bar" or "x $bar", it's not there any more.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP0ndXGPeouIeTNHoEQKkKQCgzYi+ib0msMI/h4p7uLRW7QMdBhUAn1H+
YHV9TXERaOGVzxlbdLX6gQIb
=wA5Q
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top