You don't say exactly HOW you check the return value against undef, but I'm guessing you're doing something like "if ($val eq 'undef')" or "if ($val == undef)", both of which are wrong.
The correct way is "if (defined $val)". This won't trigger any warnings.