Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: hash and array mismatch

by Anonymous Monk
on May 09, 2007 at 19:09 UTC ( [id://614480]=note: print w/replies, xml ) Need Help??


in reply to hash and array mismatch

The keys corresponding to 9-13 were repeated later in your $line, which resulted in an overwrite of the values corresponding to those keys.

For example, from the first set of print statements, position 9 corresponds to "POSITION NAME", which would look something like:

$dataPos{"POSITION NAME"} = 9;
A little further in your list you'll see "POSITION NAME" at position fifteen; the assignment statement for this would look something like
$dataPos{"POSITION NAME"} = 15;
Since this statement is executed after the first, your 9 disappears, and only 15 is stored as the value for the key of "POSITION NAME".

Repeat the above for entries 10-13, and you should see those values got overwritten.

If you want to keep all this data, you might consider making the integers your keys, and saving the text as the values. Of course, you already did that when you created the @data array.

hth.

-hershmaster

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found