- 论坛徽章:
- 8
|
- [root@RHEL6 tmp]# cat a.pl
- #!/usr/bin/perl
- use strict;
- use warnings;
- my $h;
- map { /(\d+\s+\d+)\s+(\d+)(?{push @{$h->{$1}},$2})/ } <DATA>;
- map {
- my ( $min, $max ) = ( sort @{ $h->{$_} } )[ 0, -1 ];
- my $sc = scalar @{ $h->{$_} };
- print "$_\t";
- $sc == 1 ? print "1\t@{$h->{$_}}\n" : print "$sc\t$min\t$max\n"
- } keys $h;
- __DATA__
- 111 16644211 348795021
- 111 16644211 348795368
- 111 16644211 348797001
- 111 16644211 348797826
- 111 22443489 348795333
- 111 67384560 348795445
- 111 67384560 348795879
- [root@RHEL6 tmp]# ./a.pl
- Type of arg 1 to keys must be hash (not private variable) at ./a.pl line 13, near "$h;"
- Execution of ./a.pl aborted due to compilation errors.
- [root@RHEL6 tmp]# vi a.pl
- [root@RHEL6 tmp]#
复制代码 代码好像有问题呀,大牛
回复 11# mcshell
|
|