in reply to How to make perl sort these values in order?
First off you should chomp the values you get from readline (<>), then sort them, the default sort is not numeric so something like:
You should consider chomping in a loop into an array.
I also added the use strict; use warnings;#!/usr/bin/perl use strict; use warnings; print "Type in a number."; chomp(my $n1 = <>); print "Type in another number."; chomp(my $n2 = <>); print "Type in another number."; chomp(my $n3 = <>); print "Type in another number."; chomp(my $n4 = <>); print "Type in another number."; chomp(my $n5 = <>); print "$_\n" for sort { $a <=> $b } ($n1,$n2,$n3,$n4,$n5);
You should consider chomping in a loop into an array.
|
---|
In Section
Seekers of Perl Wisdom