標(biāo)題: use strict的不解 [打印本頁(yè)] 作者: freeterman 時(shí)間: 2013-05-28 20:29 標(biāo)題: use strict的不解 [root@localhost ~]# less test
#!/usr/bin/env perl
use strict;
use warnings;
my $name = Fred;
print "hello\n" if $name =~ /red/;
[root@localhost ~]# ./test
Bareword "Fred" not allowed while "strict subs" in use at ./test line 4.
Execution of ./test aborted due to compilation errors.
[root@localhost ~]#
當(dāng)注釋了use strict的時(shí)候就正常了
[root@localhost ~]# less test
#!/usr/bin/env perl
#use strict;
use warnings;
my $name = Fred;
print "hello\n" if $name =~ /red/;
[root@localhost ~]# ./test
hello
[root@localhost ~]#