||
在Perl中如何工作?我想實現c風格||
操作。`||`在Perl中如何工作?
@ARRAY=qw(one two THREE four);
$i=0;
if(($ARRAY[2] ne "three")||($ARRAY[2] ne "THREE")) #What's the problem with this
{
print ":::::$ARRAY[2]::::::\n";
}
while(($ARRAY[$i] ne "three")||($ARRAY[$i] ne "THREE")) #This goes to infinite loop
{
print "->$ARRAY[$i]\n";
$i=$i+1;
}
如果你想知道的東西是如何工作的,閱讀機制的文檔:http://perldoc.perl.org/perlop.html#C-style-Logical-Or – 2010-09-24 15:42:52
你應該看看' perltidy'腳本,這將使你的東西更容易閱讀和維護。你也真的需要使用'use strict;使用警告;'。如果你不這樣做,你會遇到數百個perl會告訴你的可避免的問題。 – Daenyth 2010-09-24 15:45:26