Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Search in array from match in another array, print once only.

by vinoth.ree (Parson)
on Feb 22, 2013 at 10:07 UTC ( #1020118=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Search in array from match in another array, print once only.
in thread Search in array from match in another array, print once only.

Use the code below to say matched element count also, this will tell you the possible matches not only twice.

use strict; use warnings; use Data::Dumper; my %hash_count; my @array = ( "54321", "54312" , "5999" , "54352" , "12345" + ); my @original = ( "12345" , "54321" , "12355", "54321" ); foreach my $string(@array) { foreach my $string2(@original) { if ($string eq $string2) { $hash_count{$string}++; } else { unless (exists $hash_count{$string}) { $hash_count{$string} = 0; } } } } print Dumper \%hash_count; foreach (keys %hash_count) { unless ($hash_count{$_}) { print "$_ Not found\n"; } else { print "$_ found $hash_count{$_} times\n" ; } }


Comment on Re^3: Search in array from match in another array, print once only.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020118]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-08-01 11:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (8 votes), past polls