in reply to Sorting numbers
Unless you're not showing a constant or a sub definition somewhere, your code shouldn't even compile under strict. That said, there are other problems.
This line:
@num[count2] = sort ($start_bit_no);sorts a one-element list, so you'll get back out exactly what you put in. I'm not sure where count2 comes from, but if it's not a constant or a sub (and I don't think it is, based on the next line), it'll be an undefined value.
This line:
$num[count2]++;increments the value you just assigned.
You need to put the lines into an array or a list somehow (and don't forget to chomp them) and pass them to sort:
print join("\n", sort map { chomp; $_ } <IN> );
|
|---|