in reply to $_ not set in while <>
is a shorthand for
Personally I'd write
while (<>) { last if /pattern/; ... }
I find this more readable. YMMV!
HTH :)
B::Deparse can help you explore the difference
C:\>perl -MO=Deparse -e"while (<>) {}" while (defined($_ = readline ARGV)) { (); } -e syntax OK C:\>perl -MO=Deparse -e"while (<> and !/pattern/) {}" while (readline ARGV and not /pattern/) { (); } -e syntax OK C:\>
°)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: $_ not set in while <>
by Marshall (Canon) on Jun 06, 2021 at 02:59 UTC | |
by LanX (Saint) on Jun 06, 2021 at 12:46 UTC | |
by ikegami (Patriarch) on Jun 06, 2021 at 04:15 UTC | |
by Marshall (Canon) on Jun 06, 2021 at 05:02 UTC | |
by kcott (Archbishop) on Jun 06, 2021 at 06:28 UTC | |
by Marshall (Canon) on Jun 06, 2021 at 07:34 UTC | |
by ikegami (Patriarch) on Jun 09, 2021 at 05:57 UTC | |
by LanX (Saint) on Jun 09, 2021 at 14:15 UTC | |
| |
by LanX (Saint) on Jun 09, 2021 at 12:35 UTC | |
by Anonymous Monk on Jun 08, 2021 at 17:06 UTC |