Why won't the array sort?
CODE
my @data = ('PJ RER Apts to Share|PROVIDENCE',
'PJ RER Apts to Share|JOHNSTON',
'PJ RER Apts to Share|JOHNSTON',
'PJ RER Apts to Share|JOHNSTON',
'PJ RER Condo|WEST WARWICK',
'PJ RER Condo|WARWICK');
foreach my $line (@data) {
$count = @data;
chomp($line);
@fields = split(/\|/,$line);
if ($fields[0] eq "PJ RER Apts to Share"){
@city = "\u\L$fields[1]";
@city_sort = sort (@city);
print "@city_sort","\n";
}
}
print "$count","\n";
OUTPUT
Providence
Johnston
Johnston
Johnston
6