in reply to Re^4: Perl Module Object - Return fail/success with a fault string
in thread Perl Module Object - Return fail/success with a fault string

Please don't post (links to) offsite code. I prefer that you take the time to reduce your code (and problem) to a small, self-contained example.

That said, your example API can be made to work by using overload to return a false value on which you still can call methods. I'm not sure whether that's the best API though. I would (also for testing purposes) split up the call to new and the call to connect, and have the call to connect just return a false value:

my $conn = Net::Big5->new(...); $conn->connect or die $conn->error;

That way you can make the call to connect fatal (via die) if it is in void context.

  • Comment on Re^5: Perl Module Object - Return fail/success with a fault string
  • Download Code