in reply to Re^3: Converting HoA into HoH
in thread Converting HoA into AoH

Dear Zaxo,
One last thing here. I'm really sorry for not being precise earlier. I was just trying to pose the problem as simple as possible. The element of the array in my actual production code comes with white space like this:
my $HoA = { '1,2,flintstones' => [ "fred-1 foo-2", "barney-1 bar-2" ], '2,3,jetsons' => [ "george-1 foo-2", "jane-1 bar-2"], };
The key of the new hash is identified correctly, the problem is only in the values. Is there a way I can modify your code? In particular, so that it takes the element of the array as "one" entity regardless the white-space?
So that it doesn't return:
$VAR1 = [ { '1,2,flintstones' => undef, '2,3,jetsons' => undef }, { '1,2,flintstones' => 'jane-1', '2,3,jetsons' => 'foo-2' }, { '1,2,flintstones' => undef, '2,3,jetsons' => 'bar}' }, { '1,2,flintstones' => 'barney-1', '2,3,jetsons' => 'foo-2' }, { '1,2,flintstones' => undef, '2,3,jetsons' => 'bar-2}' } ];
But simply:
my $AoH = [ { '1,2,flinstones' => "fred-1 foo-2", '2,3,jetsons' => "george-1 foo-2" }, { '1,2,flinstones' => "fred-1 foo-2", '2,3,jetsons' => "jane-1 bar-2" }, { '1,2,flinstones' => "barney-1 bar-2", '2,3,jetsons' => "george-1 foo-2" }, { '1,2,flinstones' => "barney-1 bar-2", '2,3,jetsons' => "jane-1 bar-2" }, ];
I tried to modify your code by changing the type of separator. But doesn't work either. Hope to hear from you again.

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re^5: Converting HoA into HoH
by Zaxo (Archbishop) on Oct 31, 2005 at 16:57 UTC

    The problem is the same one I had with spaces in the glob. I'll post a working rewrite at top level. The only difference is to insert an escape '\' before each space. If your real data contains other things to mess up glob, treat similarly.

    After Compline,
    Zaxo