perlquestion
drock
why isn't my sort working??? Thanks perl people! : )
<code>
use warnings;
use strict;
my $file = qq(/var/adm/sa/vm);
my $vmout = qq(/var/adm/sa/vm.out);
my $cpuout = qq(/var/adm/sa/cpu.out);
open (FILE, "<$file") || die "unable to open file $!";
open (MEMOUT, ">$vmout") || die "unable to open file $!";
open (CPOUT, ">$cpuout") || die "unable to open file $!";
while (<FILE>) {
local $, = "\n";
if (/^\d+/) { s/fre//,print MEMOUT +(split)[4], $, ;}
if (/^\d+/) { s/id//,s/wa//,print CPOUT (sort {$a <=> $b} +(split)[16]),$,;} ##--## Added sort after "print CPOUT"
}
#sub num { $a <=> $b }
#my @sortlist = sort num $cpuout;
close (FILE) or warn unable to close file $!";
close (MEMOUT) or warn unable to close file $!";
close (CPOUT) or warn unable to close file $!";
__DATA__
So everyone is saying I cannot embed a sort within a
print of a FileHandle on column 16? I want to put the DATA below in numeric order.
data from $cpuout
381305
377927
381305
377927
377165
373656
373614
373614
373248
390423
390423
390255
390111
389959
</code>