Hello iThunder,
As GrandFather says, you should put text into paragraphs using <p> ... </p> tags, and you should enclose code and data in <code> ... </code> tags. I also moved your post from Perl Monks Discussion to Seekers of Perl Wisdom.
Regarding the flip-flop operator (viz., .. in scalar context), you are confusing line numbers with sequence numbers. Actually, the flip-flop operator evaluates to a boolean value, i.e., either true or false. When the operator evaluates to true, Perl, as a convenience, returns “true” in the form of a sequence number. Consider:
use strict; use warnings; my $p; while (<DATA>) { chomp; if ($p = 3 .. 5) { print "$_: \$. is $.: p is $p\n"; } } __DATA__ line 1 line 2 line 3 line 4 line 5 line 6 line 7
Output:
14:00 >perl 1020_SoPW.pl line 3: $. is 3: p is 1 line 4: $. is 4: p is 2 line 5: $. is 5: p is 3E0 14:00 >
Note that the string E0 is appended to the final true value: this “gives you something to search for if you want to exclude the endpoint.” — perlop#Range-Operators.
Update: Added printout of $..
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: flip flop operator and if statement
by Athanasius
in thread flip flop operator and if statement
by iThunder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |