perl hash值如何查询 求排错use warnings;use strict;my %a = (1 => [1,2,3,4],2 => [2,3,4,5],3 => [3,4,5,6],4 => [4,3,2,1],5 => [5,4,3,2],6 => [6,5,4,3]);sub search {my $tmp = @_;if (exists($a{$tmp})) {print "$a{$tmp}";print "\n";} else {print "

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 03:10:16
perlhash值如何查询求排错usewarnings;usestrict;my%a=(1=>[1,2,3,4],2=>[2,3,4,5],3=>[3,4,5,6],4=>[4,3,2,1],5=>[

perl hash值如何查询 求排错use warnings;use strict;my %a = (1 => [1,2,3,4],2 => [2,3,4,5],3 => [3,4,5,6],4 => [4,3,2,1],5 => [5,4,3,2],6 => [6,5,4,3]);sub search {my $tmp = @_;if (exists($a{$tmp})) {print "$a{$tmp}";print "\n";} else {print "
perl hash值如何查询 求排错
use warnings;
use strict;
my %a = (
1 => [1,2,3,4],
2 => [2,3,4,5],
3 => [3,4,5,6],
4 => [4,3,2,1],
5 => [5,4,3,2],
6 => [6,5,4,3]
);
sub search {
my $tmp = @_;
if (exists($a{$tmp})) {
print "$a{$tmp}";
print "\n";
} else {
print " \n";
}
}
chomp (my $in = );
search($in);

perl hash值如何查询 求排错use warnings;use strict;my %a = (1 => [1,2,3,4],2 => [2,3,4,5],3 => [3,4,5,6],4 => [4,3,2,1],5 => [5,4,3,2],6 => [6,5,4,3]);sub search {my $tmp = @_;if (exists($a{$tmp})) {print "$a{$tmp}";print "\n";} else {print "
print "$a{$tmp}";
改成
print "@{$a{$tmp}}";