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/07/04 17:54:39
![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](/uploads/image/z/11798503-7-3.jpg?t=perl+hash%E5%80%BC%E5%A6%82%E4%BD%95%E6%9F%A5%E8%AF%A2+%E6%B1%82%E6%8E%92%E9%94%99use+warnings%3Buse+strict%3Bmy+%25a+%3D+%281+%3D%3E+%5B1%2C2%2C3%2C4%5D%2C2+%3D%3E+%5B2%2C3%2C4%2C5%5D%2C3+%3D%3E+%5B3%2C4%2C5%2C6%5D%2C4+%3D%3E+%5B4%2C3%2C2%2C1%5D%2C5+%3D%3E+%5B5%2C4%2C3%2C2%5D%2C6+%3D%3E+%5B6%2C5%2C4%2C3%5D%29%3Bsub+search+%7Bmy+%24tmp+%3D+%40_%3Bif+%28exists%28%24a%7B%24tmp%7D%29%29+%7Bprint+%22%24a%7B%24tmp%7D%22%3Bprint+%22%5Cn%22%3B%7D+else+%7Bprint+%22)
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}}";