----- Original Message ----- From: "oldyork90" <[EMAIL PROTECTED]>
Newsgroups: perl.beginners To: <beginners@perl.org> Sent: Wednesday, September 10, 2008 10:19 AM Subject: local var with no assignment
True or false. (Trying to figure out why this would be done with no assignment).
The reason is that $/ is initialized to 'undef' inside the block. If you were reading a file, this would result in slurping the file.
my $file; { local $/; $file = <some_filehandle>; } Now do something with the file contained in $file. You can read about this in the FAQ perldoc -q "How can I read in an entire file all at once?" Chris
In the following construct, the current value of $/ is protected by localizing it to the scope of the block. In this block, the current value of $/ is not changed. { local $/; # do some things here. The value of $/ is not modified in any of the code here. } Thank you.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/