下面的代码提供的你如何格式化打印计数的输出
Female4946Male5054gender1
如何元素及其数量之间加空格的结果,为什么它打印了1阵列旁边?
#!/usr/bin/perl
use strict;
use warnings;
my @gender;
my $female=0;
while (<>) {
chomp;
my @fields = split /,/;
push @gender, $fields[5];
}
my %count;
$count{$_}++ for @gender;
print %count;
哈希值不双引号内插。 – choroba 2015-03-13 08:30:46
你说得对。我不应该发布这个。删除相应的块。 – 2015-03-13 08:31:50
@DanielBöhmer如何让他们在同一行上打印,但是他们之间有空格? – 2015-03-13 08:40:46