in reply to How to return an appropriate error from module?
#!/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";
|
|---|