The break keyword is not used to exit a while loop. It's used to break out of a "given()" block. Use last to break out of a while loop. perldoc -f break perldoc -f last
$a and $b are built-in global vars used in sort routines and it's best not to us them outside of that context.
Input received via the <> operator will include the line terminator at the end of that data which should be removed. That is done via the chomp function. perldoc -f chomp
Comment