perl 退出函数问题

[root@node01 ~]# cat a2.pl 
sub  test {
 $i=4;
 if ($i==5){
   while (1==1){
     $i=$i-1;
    if ($i==0){
    print "xxxxxx
";
    return $i.'aa';
    }
   }
}
print "aaaaaa
";
return $i;
};

print test();

[root@node01 ~]# perl a2.pl 
aaaaaa
4[root@node01 ~]# 

[root@node01 ~]# cat a2.pl 
sub  test {
 $i=5;
 if ($i==5){
   while (1==1){
     $i=$i-1;
    if ($i==0){
    print "xxxxxx
";
    return $i.'aa';
    }
   }
}
print "aaaaaa
";
return $i;
};

print test();

[root@node01 ~]# perl a2.pl 
xxxxxx
0aa[root@node01 ~]# 

原文地址:https://www.cnblogs.com/hzcya1995/p/13349621.html