in reply to using multiple conditionals in a while(test)
In a limited set of cases, Perl applies special treatment to while loops. One such case is when the condition is a read from a file.
In these special cases while( COND ) { gets translated into while( defined( local $_ = COND ) ) {.
But for this to happen, COND has to be a 'simple' condition.
Your example:
while( (<FP>) && (!/^_stop\n/) ) {
doesn't satisfy this requirement.
To compensate, you would have to explicitly code that to use $_. Ie.
while( defined( local $_ = <FP> ) and ! /^_stop\n/ ) {
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using multiple conditionals in a while(test)
by jwkrahn (Abbot) on Dec 04, 2010 at 07:12 UTC | |
by BrowserUk (Patriarch) on Dec 04, 2010 at 07:51 UTC | |
by How09 (Novice) on Dec 04, 2010 at 14:25 UTC |