in reply to convert array of hash into formatted one

Just iterate over the array with for, use the dereference operator -> to access the inner hash'es values.
#!/usr/bin/perl use warnings; use strict; my @arr = ( { case => 'case1', id => '001', name => 'raja', degree => 'bcom' }, # ... ); my $case = q(); for my $hash (@arr) { if ($hash->{case} ne $case) { print ucfirst $hash->{case}, ":\n"; $case = $hash->{case}; } print "$hash->{id}) $hash->{name}, $hash->{degree}\n"; }

You have to be sure that the cases are continuous in the data structure. If they aren't, you'll have to sort the array.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: convert array of hash into formatted one
by Anonymous Monk on Aug 06, 2015 at 03:48 UTC
    Hi All,
    Thanks all for your prompt response. Now i got an idea how to do this.
    Thanks again.