in reply to Re^4: Help extracting pattern of data
in thread Help extracting pattern of data

My data is incremental so the same content with different values get appended to __DATA__ over time.

I'm guessing a bit here, but it sounds like you will wind up with an Array-of-Hashes structure (see perldsc). If so, and building on davido's JSON code, try something like (untested):

my @fields = qw(latestTime eCompressed eUncompressed iCompressed iUnco +mpressed); for my $i (0 .. $#$structure) { my $hr_record = $structure->[$i]; print qq{record $i: }; for my $field (@fields) { print qq{$field is $hr_record->{$field}, }; } print qq{\n}; }

Replies are listed 'Best First'.
Re^6: Help extracting pattern of data
by spikeinc (Acolyte) on Jan 27, 2014 at 05:11 UTC
    Thankyou Anomalous! It helped. I had to modify it a bit as it did not allow me to take it as an array. But the below code worked :)
    while(my $k = each %$structure) { for my $field (@fields){ print qq{$field = $structure->{$field}\n }; } }

    I will now try to work on manipulating the data from the fields output and get back if I have questions. Thanks a lot for your advice n help :)

      hey, I am having some trouble looping through the structure. The above code was fine when I had one entry of json data. But its printing the same line as many times as each key in $structure. How can I loop such that I print unique entries from the structure.
        Closing this thread, opening another one so as to organize.