in reply to How to return an appropriate error from module?

You could return a tuple of (ERRMSG, VALUE). This makes it easy to return errors. It has the benefit of being very lightweight. Here's a script for testing:
#!/usr/bin/perl -w use strict; sub chk_phn { local ($_) = @_; return "missing input" unless defined $_; return "empty input" if $_ eq ""; return "invalid character" if /[^-\d]/; s/-//g; return (undef, $_); } my ($err, $res) = chk_phn @ARGV; $err = "UNDEF" unless defined $err; $res = "UNDEF" unless defined $res; print "<$err><$res>\n";