in reply to I ve an urgent issue..

I second halfcountplus's point about the code tags, especially as it is urgent.

You were heading in the right direction with your first for loop - but it got away from you (don't you just hate it when that happens?). Use strict and warnings _and_ don't comment them out. :-)

Read up on Perl data structures, what you needed was a hash of arrays. e.g. Data Types and Variables

Good luck!

#!/usr/bin/perl use warnings; use strict; my @country = ( "Australia", "south","Austria","America","India","Zimbabwe" ); # build a table - a hash of arrays (HoA) my %table; foreach my $country (@country) { my $init = uc substr($country,0,1); push @{$table{$init}}, $country; } # output the table for my $letter (sort keys %table){ print qq{$letter = }; for my $country (sort @{$table{$letter}}){ print qq{$country }; } print qq{\n}; }
produces
A = America Australia Austria I = India S = south Z = Zimbabwe
updated: added link