One problem may be that you are using the logical or operator in list context where there are precedence issues (at least with die). Try using or instead.
open(RPT,">$rptname")||warn "Unable to open report file: $!\n";
should be:
open(RPT, ">$rptname") or warn "Unable to open report file: $!\n";