The following supposed to sort the file by model. However, it does not do that. May be I do not understand the logic. Please help.
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
$query = new CGI;
open(INF, "<car1.out" or dienice("Couldn't open auto.out for reading: $! \n"
@kites = <INF>;
close (INF);
foreach $i (sort bycity @kites) {
chomp ($i);
($name,$add,$city,$state,$zip,$make,$photo,$model,$color,$mile,
$eyear,$price,$email,$tele,$time,$comment1,$month,$day,$year)=split(/\|/, $i);
print " $city - \$$model<br>\n";
# this is the same as $count = $count + 1;
}
sub bycity {
@a = split (/\|/,$a);
@b = split(/\|/,$b);
$a[7] <=> $b[7];
}
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
$query = new CGI;
open(INF, "<car1.out" or dienice("Couldn't open auto.out for reading: $! \n"
@kites = <INF>;
close (INF);
foreach $i (sort bycity @kites) {
chomp ($i);
($name,$add,$city,$state,$zip,$make,$photo,$model,$color,$mile,
$eyear,$price,$email,$tele,$time,$comment1,$month,$day,$year)=split(/\|/, $i);
print " $city - \$$model<br>\n";
# this is the same as $count = $count + 1;
}
sub bycity {
@a = split (/\|/,$a);
@b = split(/\|/,$b);
$a[7] <=> $b[7];
}
print <<EndHTML;
EndHTML
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}