My guess is that it is because you are forgetting to strip the newline character from each line of the file before you do your sort.
my @file = <FIN>; chomp @file; #<--- insert this line But don't forget that if you do this, you'll have to put the newlines back in before you print it the results to the screen. -----Original Message----- From: anu p [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 31, 2005 9:55 AM To: [email protected] Subject: Numeric sort warning Hi, I have written a simple script that does numeric or ascii sort based on the command line args. When I run it, my output is ok but I get the warning "Argument "\x{a}" isn't numeric in sort at sort.pl line 19, <FIN> line 8." This is my script #!/usr/bin/perl use strict; use warnings; my $numeric = 0; my $input = shift; if($input eq "-n"){ $numeric = 1; $input = shift; } open FIN, $input or die "couldn't open $input for read $!\n"; my @file = <FIN>; if($numeric){ @file = sort {$a <=> $b} @file; } else{ @file = sort @file; } print @file; Can anyone let me know what's the problem? Thanks, Anu. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
