Just can't make this array comparison work

J

J. Gleixner

bjjnova said:
this looks promising; tho' I have no idea what AoA and AoH mean.

First, avoid top posting.

Second, see:

perldoc perldsc

It will provide you with many examples of common data structures.
 
X

xhoster

bjjnova said:
A and B are arrays with data records.

There is no precise meaning in Perl of the word "record". Records are
generally stored either as arrays, or as hashes (or as objects, but I'll
ignore that for now). So an array of records is usually either an array of
arrays, or an array of hashes. Alternatively, a record could be neither
an array nor a hash, but rather a flat string which needs to be parsed out
into individual fields each time they are needed. In any event, we can't
help you much more than we already have if you don't show us what you mean
by "record" in this context, preferably by showing some of the code you
already have so far.

Xho
 
J

Jürgen Exner

bjjnova wrote:
[long explanation snipped]

I wasn't able to understand your lengthy explanation, but it appeared to me
as if you want to compute the intersection of two arrays. If so then maybe
the FAQ "How do I compute the difference of two arrays? How do I compute
the intersection of two arrays?" would be helpful.

jue
 
J

Joe Smith

bjjnova said:
i think I do need hashes (I didn't know they existed before this series
of posts);

You do need hashes. You want to learn them.
if A is an array of everyone's name and address and phone number in NY
and B is an array of everyone's name in NYC, and I want everyone's
address and phone number in NYC, won't setting A=B simply destroy
everything I'm trying to grab? That is, it will make a replica of B,
so I will still have everyone's name in NYC but none of their addresses
or phone #'s.

%phone_and_addr_by_name = ('John Doe'=>'800-555-1212 123 Main, NYC, NY',
'Jane Doe'=>'212-555-1212 456 78th Ave, Brooklyn, NY', ...);
@names_NYC = ('John Doe', 'Jim Brown');
@phone_and_addr_in_NYC = @phone_and_addr_by_name{@names_NYC};

That last step grabs several values from %phone_and_addr_by_name
by using a list of keys.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,177
Messages
2,570,954
Members
47,507
Latest member
codeguru31

Latest Threads

Top