in reply to how do I "initialize" $_
The default scalar $_ (see perlvar) is assigned to in some cases, but not all; you've chosen one of the "not all" cases. A while-loop like
is reallywhile (<FILEHANDLE>) { print; }
and likewisewhile (defined($_ = <FILEHANDLE>)) { print $_; }
isfor (<FILEHANDLE>) { print; }
(Note that the while-loop will read and print the filehandle line-by-line, but the for-loop will read all lines of the file at once (could be a lotta lines!) and then print the lines one-by-one.) See perlsyn.for $_ (<FILEHANDLE>) { print $_; }
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how do I "initialize" $_
by Anonymous Monk on Oct 11, 2018 at 06:46 UTC | |
by Marshall (Canon) on Oct 12, 2018 at 19:47 UTC | |
by haukex (Archbishop) on Oct 13, 2018 at 08:47 UTC | |
by Marshall (Canon) on Nov 01, 2018 at 06:57 UTC | |
by AnomalousMonk (Archbishop) on Oct 13, 2018 at 02:10 UTC | |
by Marshall (Canon) on Oct 13, 2018 at 04:21 UTC | |
by AnomalousMonk (Archbishop) on Oct 13, 2018 at 06:21 UTC | |
|