in reply to How do I report an error back to the user of my object?

The above are great solutions, but there is one more.
You may have seen modules that have something like $Foo::errstr or the likes. Setting up something like that isn't too hard:

package Foo::Bar; our $error = ""; sub new { my( $class, @args ) = @_; my $self = bless( \@args, $class ); unless( $self->method_that_might_fail() ) { $Foo::Bar::error = "O noes"; return undef; } return $self; }

Of course, you will have to change that to fit your style, and it is probably a good idea to push the error setting to a separate subroutine.

~Thomas~
confess( "I offer no guarantees on my code." );

Replies are listed 'Best First'.
Re^2: How do I report an error back to the user of my object?
by polymorpheus (Novice) on Jun 05, 2012 at 13:11 UTC
    I would highly suggest you do not take an approach like this. Exception based errors (die/eval) are far superior in many respects. If you are not convinced yet, do some research! Also look at all the monks! Most have already suggested die() and for good reasons!