Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

HI!!

This may be fairly easy but I am not seeing the solution.

I'm parsing and viewing data from a comma delimited file using the following (subset of total program):

my @data = split(/,/, $line); foreach my $i ( 0..$#data ) { $dataPos{$data[$i]} = $i; print "$data[$i] -- > $i\n"; } print Dumper ( \%dataPos );
The first print within the 'foreach' loop yields (please ignore the '' values -- I'll fix those soon:
WELL -- > 0
ENTRY ID -- > 1
DISPENSATION ORDER -- > 2
CREATOR -- > 3
CREATION DATE -- > 4
SAMPLE ID -- > 5
DESCRIPTION -- > 6
RUN ID AND DATE -- > 7
TOTAL QUALITY -- > 8
POSITION NAME -- > 9
RESULT -- > 10
QUALITY -- > 11
EDITED -- > 12
-- > 13
TOTAL QUALITY -- > 14
POSITION NAME -- > 15
RESULT -- > 16
QUALITY -- > 17
EDITED -- > 18
-- > 19
-- > 20

while a 'Dumper' print out of the dataPos hash yields:
$VAR1 = {
' TOTAL QUALITY' => 14,
'RESULT' => 16,
'CREATOR' => 3,
' ' => 20,
'TOTAL QUALITY' => 8,
'WELL' => 0,
'SAMPLE ID' => 5,
'DISPENSATION ORDER' => 2,
'POSITION NAME' => 15,
'QUALITY' => 17,
'DESCRIPTION' => 6,
'ENTRY ID' => 1,
'CREATION DATE' => 4,
'EDITED' => 18,
'RUN ID AND DATE' => 7
};

Could someone please tell me what happened to values 9 - 13 in the hash and when these two are not equivalent?

Thank you!!


In reply to hash and array mismatch by dana

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 rifling through the Monastery: (5)
As of 2024-04-23 18:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found