lupey has asked for the wisdom of the Perl Monks concerning the following question:
I understand that local $/ saves a copy of $/ and it sets it to undef. But, what I wasn't expecting is when I run my script with the perl debugger and type x \$/ after local $/, it still shows that the value is \n. But, when I print $/ after performing local $/, it outputs the empty string (as expected). I'm not sure I understand why x \$/ in the perl debugger still shows it as a newline.
Thank you for your help,
lupey
#!/usr/bin/perl print "RS is:<$/>\n"; # typing 'x \$/' in debugger gives this (as expected) #0 SCALAR(0x10141238) # -> ' #' changeRS(); sub changeRS { local $/; print "RS is:<$/>\n"; # typing 'x \$/' in debugger gives this (*NOT* as expected) #0 SCALAR(0x103b8f68) # -> ' #' } print "RS is:<$/>\n"; # typing 'x \$/' in debugger gives this as expected #0 SCALAR(0x10141238) # -> ' #'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: confused about local $/ in perl debugger
by fishbot_v2 (Chaplain) on May 24, 2005 at 13:43 UTC | |
by lupey (Monk) on May 24, 2005 at 14:26 UTC | |
by fishbot_v2 (Chaplain) on May 24, 2005 at 14:47 UTC | |
|
Re: confused about local $/ in perl debugger
by tlm (Prior) on May 24, 2005 at 13:42 UTC |