in reply to if not defined

If there's no difference between undef and the nul string (""), you could canonize the values.
for ($pname, $policy_ur, $odate) { if (!defined($_)) { $_ = ''; } } if ($pname ne '' && $policy_ur ne '' && $odate ne '') { ... }
Or the other way around:
for ($pname, $policy_ur, $odate) { if (defined($_) && $_ eq '') { undef $_; } } if (!defined($pname) && !defined($policy_ur) && !defined($odate)) { ... }