in reply to Reduce Redundant Repetition

You might consider replacing something like this...
if (defined $opt_targ){ $targ = $opt_targ } else {$targ='localhost';}
with something like this...
$targ = $opt_arg; $targ ||= 'localhost';
...following the "this breaks if zero is an acceptable value" admonition previously stated above...