just please give us a sample input and output (a bit more, if possible) and also please use
[code][/code] to keep formatting of your code.
try the following:
1. use
#!/usr/bin/perl -w at the beginning ( so add -w )
2. add this as second line:
use strict;
these will ensure you will write better code
3. the line:
next if($_ eq undef); is meaningless,
$_ always has value (because otherwise the while loop will be terminated)
4. you ought to need check if
@arr has 2 elements