文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>FOR和WHILE 的一点很重要的区别

FOR和WHILE 的一点很重要的区别

时间:2008-05-16  来源:yjc0407

=head1 DESCRIPTION
the different of while and for;
only next exist  the loop increase in for will increase
when exist for(),for example for ($i;$i<10;$i++) but if so for($i;$i<10;){$i++} the $i will not increase
if appear next,the same as next in while loop;

use strict;
use warnings;

sub test_for{
    my $filename = shift @_;
    local (*FN);
    my(@dt,@dc,@de);
    my ($i,$BNR);
    @dt = @dc = @de = ();
    open FN,"<$filename";
    for ($i=0; <FN>;++$i){
    chomp;
    ($dt[$i],$dc[$i],$de[$i]) = split /\s+/;
    next if ("002" lt substr($dt[$i],3,3));
    last if ("M" lt substr($de[$i],0,1));
    
    print substr($de[$i],0,1);
    #++$i;
    }
    close(FN);
    $BNR = $i;
    print $BNR;
   
}

my $fil = shift(@ARGV);
test_for($fil);

=POD file.txt
$ARGV[0] = file.txt

20000104 -0.85 L
20000104 -0.85 Y
20000412 4.65 Y
20000412 4.65 IBM
20000314 -9.18 MSFT
20000331 -6.80 MSFT

= cut
相关阅读 更多 +
排行榜 更多 +
坦克战争世界

坦克战争世界

模拟经营 下载
丛林反击战

丛林反击战

飞行射击 下载
几何飞行安卓版

几何飞行安卓版

飞行射击 下载