I have this program that supposed to sort data. However, it stops at the first record.
open(INF,"<apart.out") or dienice("Couldn't open apart.out for reading: $! \n");
@data = <INF>;
close(INF);
foreach $i (sort bycity @data) {
chomp($i);
($name,$address,$city,$state,$zipcode,$location,$photo,$squarefoot,$bed,$bath,$lv1,$lv2,$lv3,$lv4,$lv5,$lv6,$lv7,$lv8,$askingprice,$security,$deposit,$email,$telephone,$timetocall,$comment1,$month,$day,$year) = split(/\|/,$i);
sub bycity {
@a = split (/\|/,$a);
@b = split(/\|/,$b);
$a[3] cmp $b[3] || $a[2] cmp $b[2] || $a[9] cmp $b[9] || $a[18] cmp $b[18] ;
}
open(INF,"<apart.out") or dienice("Couldn't open apart.out for reading: $! \n");
@data = <INF>;
close(INF);
foreach $i (sort bycity @data) {
chomp($i);
($name,$address,$city,$state,$zipcode,$location,$photo,$squarefoot,$bed,$bath,$lv1,$lv2,$lv3,$lv4,$lv5,$lv6,$lv7,$lv8,$askingprice,$security,$deposit,$email,$telephone,$timetocall,$comment1,$month,$day,$year) = split(/\|/,$i);
sub bycity {
@a = split (/\|/,$a);
@b = split(/\|/,$b);
$a[3] cmp $b[3] || $a[2] cmp $b[2] || $a[9] cmp $b[9] || $a[18] cmp $b[18] ;
}