Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
My initial reaction is to ask why you're doing it this way? Arrays and list indexes are not your friend, usually. Hashes, on the other hand, are:
use strict; use warnings; my %entity = ( A1 => { customerID => '007', ssn => '999-99-9999', relationship => 'self', }, B1 => { customerID => '008', ssn => '888-88-8888', relationship => 'spouse', }, C1 => { customerID => '009', ssn => '777-77-7777', relationship => 'son', }, ); foreach my $e (keys(%entity)) { print "$e\n"; print "$entity{$e}{'customerID'}\n"; print "$entity{$e}{'ssn'}\n"; print "$entity{$e}{'relationship'}\n"; }

And for that matter, this code could be improved, but you're starting to get the idea- you might want to change the primary key away from entity to customerID, for example, but it still largely holds. You're doing a lot of data thrashing, but not what I assume your intended goals are.

If you want to continue using arrays, I definitely suggest you follow jeffa's approach, then.

As far as putting them into a table for referencing purposes, depending on what you mean, I may have just done that for you. If you're looking to put them in a database, you should check out DBI.

As far as what's causing your problems, I can't tell from the code you presented above. At a glance, it looks like it should work.

Hope this helps!

--jwest

-><- -><- -><- -><- -><-
All things are Perfect
    To every last Flaw
    And bound in accord
         With Eris's Law
 - HBT; The Book of Advice, 1:7

In reply to Re: Table building confusion Help Wanted by jwest
in thread Table building confusion Help Wanted by basicdez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found