[mplspm]: How to overload $!

Mark Allen mark.allen at shavlik.com
Thu Apr 29 13:23:11 CDT 2004


I have some LWP::UserAgent code in a module where I'd like to overload
$! on failure.

Example:

my $r=$ua->request($request)

if ($r->is_success) {
  $self->{content} = $r->content;
} else {
  $! = "Something bad happened.";
  return undef;
}

perl -wc Foo.pm says "syntax OK!" but in my test program t.pl, when I
run it, it says, "Argument "ERROR=3" isn't numeric in scalar assignment
at foo/bar/Foo.pm line 237."

What's the "right way" to do this?  I've been googling for about 30
minutes and not finding the right answer.

Thanks!

--Mark


--------------------------------------------------
Minneapolis Perl Mongers mailing list

To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.



More information about the Mpls-pm mailing list