Feng Yue wrote:
Hi,
Hello,
I have a problem about grep in Perl.
I'd like to use grep in a if clause like this
if( *grep /^\$/, @array* ){
...
}
This works well.
However, when I add some more tests in this if, like this:
if( *0 || grep /^\$/, @array || 0* ){
...
}
this if will never be true even when there are strings begin with "$"
@array. And to make this work, I have add () around grep, like this.
if( 0 || *(grep /^\$/, @array)* || 0 ){
...
}
Is this because OR '||' has higher precedence than comma "," in perl ?
Yes.
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/