Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by vinoth.ree (Monsignor)
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?
[ambrus]: MLX: if it's a work email, then it's probably not Uncle Sam that matters, but what the account managing server at work thinks your name is. Those can differ. For example, we've had two co-workers with identical real name at one point,
[ambrus]: so one got a stupid suffix in the email account (people have email address based on their real name here usually).

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2017-01-19 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.