please help,
I'm a newbie so please be patient.
I have a file, say file.txt.
The contents of the file are:
z
x
h
w
a
how do i open this file and sort it, and output it into a different file, say sorted.txt?
The code I've tried doesn't work:
$file="file.txt";
open FILE, $file or die "cannt open $stuff for read:$!";
while(<FILE>){
@INFO = $_;
$out="sorted.txt";
open OUT, ">>$out" or die "cannot open $out for write :$!";
foreach $letter(@INFO){
$sorted=$sorted+$letter;
}
print "$sorted";
print OUT "$sorted";
}
please can someone tell me what i need to do?
what would the correct code be?
Any help greatly appreciated....
I'm a newbie so please be patient.
I have a file, say file.txt.
The contents of the file are:
z
x
h
w
a
how do i open this file and sort it, and output it into a different file, say sorted.txt?
The code I've tried doesn't work:
$file="file.txt";
open FILE, $file or die "cannt open $stuff for read:$!";
while(<FILE>){
@INFO = $_;
$out="sorted.txt";
open OUT, ">>$out" or die "cannot open $out for write :$!";
foreach $letter(@INFO){
$sorted=$sorted+$letter;
}
print "$sorted";
print OUT "$sorted";
}
please can someone tell me what i need to do?
what would the correct code be?
Any help greatly appreciated....