in reply to Re: Having an Issue updating hash of hashes
in thread Having an Issue updating hash of hashes

This bit will stop working once you start getting multi-digit IDs:

$key = $1 if /^ID=(.)/;

You'll want this instead:

$key = $1 if /^ID=([^\s]+)/;

Otherwise you'll end up silently overwriting previous entries.

Replies are listed 'Best First'.
Re^3: Having an Issue updating hash of hashes
by 2teez (Vicar) on Jul 05, 2014 at 18:54 UTC

    This bit will stop working once you start getting multi-digit IDs:

    $key = $1 if /^ID=(.)/;
    Obviously, BUT the OP data set doesn't say otherwise and I don't intend to think for the OP!
    Am only using the OP dataset provided with that the line suffices!

    Update:

    You'll want this instead:

    $key = $1 if /^ID=([^\s]+)/;
    Otherwise you'll end up silently overwriting previous entries.

    And what happens if the OP has two or ID with the same value, even with the code above?! Oops!!
    Maybe the OP first intention of using a counter will do for all intent and purpose!

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me