in reply to Re: Re: Extracting a hash reference from a string
in thread Extracting a hash reference from a string

Yes, you are right. The require opcode always appends the string to $@, regardless if it is an object or not. Note that this will stringify your reference and then decrement the reference count to your hash. So don't try to access it through the pointer provided by the stringification (which would be a bad idea anyways).

I guess this means you will have to use a different error mechanism if your required modules can fail in a variety of ways. You could adopt some convention of package variables, like this:

eval { require MyModule } if (defined $MyModule::Error) { print "Couldn't load MyModule: ", $MyModule::Error->{message}, + "\n"; # ... }
and in your MyModule.pm file:
package MyModule; our $Error; # ... if ($some_error) { $Error = {err = 42, message => 'Sorry, my fault!'}; die; # or maybe just 'return 0;' }