greenhorn has asked for the wisdom of the Perl Monks concerning the following question:
It was here that I saw recently how $/ could be temporarily redefined within a block. For example:
{ local $/ = ''; chomp(@array = <FILEHANDLE>); }
I thought I would shorten it slightly:
{ local $/; # ( or: local undef $/; ) chomp(@array = <FILEHANDLE>); }
This made a considerable difference in the contents of "@array". In the first case<KBD> (local $/ = '';) </KBD>entire paragraphs were slurped into each element of the array. But in the second<KBD> (local $/;) </KBD> this didn't happen; each element within the array was a single line from the input file.
How is it that<kbd style=color:red> '' </kbd>is so different from no value (or so different from "undef")?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Altering the value of
by plaid (Chaplain) on Jul 03, 2000 at 05:14 UTC | |
|
Re: Altering the value of
by davorg (Chancellor) on Jul 03, 2000 at 11:59 UTC | |
by greenhorn (Sexton) on Jul 04, 2000 at 02:42 UTC |