in reply to Hash of array of hashes

Solved!

use strict; my $exampleinput = q(1 | p1=v1,p2=v2 | p3=v3,p4=v4); sub processrow( $ $ ) { my ( $hashref, $input ) = @_; my @condition = split( /\s*\|\s*/, $input ); my $index = shift( @condition ); $hashref->{$index} = [ map { { map { $_->[0] => $_->[1] } map { [ split( /=/, $_ ) ] } map { split( /,/, $_ ) } $_ } } @condition ]; } my %examplehash = (); processrow( \%examplehash, $exampleinput ); { use Data::Dumper; print( Dumper( \%examplehash ) ); }

Produces:

$VAR1 = { '1' => [ { 'p2' => 'v2', 'p1' => 'v1' }, { 'p3' => 'v3', 'p4' => 'v4' } ] };

Replies are listed 'Best First'.
Re^2: Hash of array of hashes
by Anonymous Monk on Jul 08, 2005 at 06:51 UTC
    Thanks, that was really fast and really good.