in reply to simplify the code
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @sur = ( { one => 'USA', two => 'GOD', three => 690557, four => 'hello how +are u', }, { one => 'USA', two => 'GOD', three => 690557, four => 'I am fine' +, }, { one => 'UK', two => 'GOD', three => 690558, four => 'I am Okay' +, }, ); my %h; foreach my $row ( @sur ){ my $three = $row->{ three }; $h{ $three } .= exists $h{ $three } ? "####" . $row->{ four } : join "<-->", @{ $row }{ qw/one two four/ }; } print Dumper \%h;
As mentioned by others your data structure seems a bit strange, but maybe it’s just example code.
Makeshifts last the longest.
|
|---|