in reply to Re: duplicate lines in array
in thread duplicate lines in array
use strict; use warnings; my @rec = ( 'N(8) -- H(15) .. O(9)', 'N(8) -- H(15) .. N(8)', 'N(8) -- H(16) .. O(9)', ); my %count; for (@rec) { /(H\(\d+\))/ && do { push @{$count{$1}}, $_ } } for (keys %count) { if ($#{$count{$_}}) { print "$_\n" for @{$count{$_}} } } __END__ # another go... $,="\n"; for (keys %count) { print @{$count{$_}} if $#{$count{$_}} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: duplicate lines in array
by Skeeve (Parson) on Jan 23, 2004 at 14:30 UTC | |
by Roger (Parson) on Jan 23, 2004 at 14:43 UTC | |
by Fletch (Bishop) on Jan 23, 2004 at 15:01 UTC | |
by Skeeve (Parson) on Jan 23, 2004 at 15:15 UTC |