#!/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; }
In reply to Re: Creating hash: Key is unique string in array element, value is number of times it appears
by Khen1950fx
in thread Creating hash: Key is unique string in array element, value is number of times it appears
by putmant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |