perl的小问题,帮忙看一下,刚学,都不懂。
#!/usr/bin/perlmy@arr=();push@arr,"000000001";push@arr,"000002000";push@arr,"001A004B...
#!/usr/bin/perl
my @arr=();
push @arr,"000000001";
push @arr,"000002000";
push @arr,"001A004B0";
while( my $out =shift @arr)
{
$out++;
my $str=sprintf("%09d",$out);
print $str,"\n";
}
输出结果:
E:\Perl_test>perl push.pl
000000002
000002001
000000002
程序是别人的,告诉我为什么会出这种结果。字符串++?搞什么?上面的数字几进制的?字符串?
还有这里为什么不能加 :use strict
加了以后报错。
E:\Perl_test>perl push.pl
Global symbol "@arr" requires explicit package name at push.pl line 4
Global symbol "@arr" requires explicit package name at push.pl line 5
Global symbol "@arr" requires explicit package name at push.pl line 6
Global symbol "@arr" requires explicit package name at push.pl line 7
Execution of push.pl aborted due to compilation errors.
关于use strict 后面加;就解决了。那么帮忙看一下输出结果,尽量详细点,感激不尽。 展开
my @arr=();
push @arr,"000000001";
push @arr,"000002000";
push @arr,"001A004B0";
while( my $out =shift @arr)
{
$out++;
my $str=sprintf("%09d",$out);
print $str,"\n";
}
输出结果:
E:\Perl_test>perl push.pl
000000002
000002001
000000002
程序是别人的,告诉我为什么会出这种结果。字符串++?搞什么?上面的数字几进制的?字符串?
还有这里为什么不能加 :use strict
加了以后报错。
E:\Perl_test>perl push.pl
Global symbol "@arr" requires explicit package name at push.pl line 4
Global symbol "@arr" requires explicit package name at push.pl line 5
Global symbol "@arr" requires explicit package name at push.pl line 6
Global symbol "@arr" requires explicit package name at push.pl line 7
Execution of push.pl aborted due to compilation errors.
关于use strict 后面加;就解决了。那么帮忙看一下输出结果,尽量详细点,感激不尽。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询