#!/usr/bin/perl
use 5.010;
my $Verbose = $ENV{VERBOSE};
print "I can talk to you!\n" if $Verbose;
#!/usr/bin/perl
use 5.010;
my $Verbose = $ENV{VERBOSE} // 1;
print "I can talk to you!\n" if $Verbose;
# ./false.pl
I can talk to you!
#!/usr/bin/perl
use 5.010;
foreach $try (0, undef, '0', 1, 25) {
print "Trying [$try] ---> ";
my $value = $try // 'default';
say "\tgot [$value]";
}
# ./false.pl
Trying [0] ---> got [0]
Trying [] ---> got [default]
Trying [0] ---> got [0]
Trying [1] ---> got [1]
Trying [25] ---> got [25]
# ./false.pl
Use of uninitialized value $name in printf at ./false.pl line 7.
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |