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) # -> ' #'
In reply to confused about local $/ in perl debugger by lupey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |