in reply to Re^3: .. operator and not including the condition of right operand
in thread .. operator and not including the condition of right operand
I realize that 0E3 means 0 in numeric context; that's precisely the point. In fact it is "a true zero", because in string context it evaluates to true. The nice thing about this is that simply by prepending a minus sign (or 0+, or 0!=) to the expression one selectively alters the truth value only of the value returned by .. when its right operand is matched; the truth of all the other values returned by this operator remains unchanged. Therefore, with a tiny change one can choose between keeping or discarding the line corresponding to a right-operand match.
BTW, to use /E/ for the original problem, you'd need two tests and an assignment:
which is significantly longer and more involved thanif ( my $count = /^1(.*)/../^0(.*)/ and $count !~ /E/ )
To use a regex to solve this problem one would need /^\d+$/:if ( -( /^1(.*)/../^0(.*)/ ) )
(This is basically one of the solutions that Roy Johnson proposed.)if ( ( /^1(.*)/../^0(.*)/ ) =~ /^\d+$/ )
the lowliest monk
|
|---|