1

Perl program for sorting an array not working

view story
linux-howto

http://stackoverflow.com – I am new to Perl programming.... I wrote a simple script for sorting of numbers in an array but the script is not working as expected. Please help me with this. #!/usr/bin/perl print ("Enter the numbers...... Please enter a blank space at the end\n"); $input = <STDIN>; chop ($input); $a = 1; until ( $input == "" ) { @array[$a-1] = $input ; $a++; $input = <STDIN>; chop ($input); } print ("@array\n"); $count = 1; $y = 1; while ( $count < @array ) { if ( $array[$y-1] > $array[$y] ) { @array[$y-1,$y] = @array[$y,$y-1]; $y++; } $count++; } pr (HowTos)