$ cat country
Chicago,USA
Frankfurt,Germany
Berlin,Germany
Washington,USA
Helsinki,Finland
New York,USA
#!/usr/bin/perl -w use strict; my %table; my ($city,$country); while (<>) { chomp; my ($city,$country) = split /,/; push @{$table{$country}},$city; } foreach $country (sort keys %table){ print @H_301_78@"$country:"; my @citIEs = @{$table{$country}}; print join @H_301_78@',', sort @citIEs; print @H_301_78@".\n"; }
result:
$ perl country.pl country Finland:Helsinki. Germany:Berlin,Frankfurt. USA:Chicago,New York,Washington.
总结以上是内存溢出为你收集整理的perl引用的实例全部内容,希望文章能够帮你解决perl引用的实例所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)