in reply to Creating hash: Key is unique string in array element, value is number of times it appears

I would try something more like this:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper::Concise; my(@array) = qw( 1111599 AB563244.1 Streptococcus macedonicus str. W28 + 1111215 AB563262.1 Streptococcus equinus str. MTS6 ); print Dumper( "Occur twice: @{numbers(\@array, 2);}" ); sub numbers { my ($newArray, $n) = (shift @_, shift @_); my(%count)= (); my(@temp_arr) = grep( {$count{$_} == $n;} grep ({++$count{$_} == 1;} @$newArray)); print "\%count:\n"; while ( my ($key, $value) = each(%count) ) { print Dumper( "$key => $value" ); } return \@temp_arr; }
  • Comment on Re: Creating hash: Key is unique string in array element, value is number of times it appears
  • Download Code