Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Compare two index lists

by monktim (Friar)
on Aug 11, 2003 at 17:19 UTC ( [id://282949]=note: print w/replies, xml ) Need Help??


in reply to Compare two index lists

The data set seems small enough. You can store all the list data in a hash. Since the hash key is unique you won't hjave duplicate data when you get the keys. You can use the value field to store the number of times the data is found.
use strict; use warnings; my @list_a = ( 'a'..'g'); my @list_b = ( 'A'..'C', 'a'..'c'); my %count; $count{$_}++ foreach (@list_a, @list_b); foreach (sort keys %count) { print "$_ appears $count{$_} time.\n" if $count{$_} == 1; }

Replies are listed 'Best First'.
Re: Re: Compare two index lists
by princepawn (Parson) on Aug 11, 2003 at 17:41 UTC
    He used regular expressionn matching... so your example is fine if the hash is tied via Tie::Hash::Regex or Tie::Hash::Approx, but otherwise...

    Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

      I agree but it seemed like he was looking for any solution that worked. "I have used different methods of looking for a match.(eq, ==, /^var2$/)". Thanks for pointing it out.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-03-28 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found