NAME

Errno::AnyString - put arbitrary strings in $!

VERSION

Version 0.03

SYNOPSIS

use Errno qw/EIO/;
use Errno::AnyString qw/custom_errstr/;

$! = custom_errstr "My hovercraft is full of eels";
print "$!\n"; # prints My hovercraft is full of eels

my $saved_errno = $!;

open my $fh, "<", "/no/such/file";
print "$!\n"; # prints No such file or directory

$! = EIO;
print "$!\n"; # prints Input/output error

$! = $saved_errno;
print "$!\n"; # prints My hovercraft is full of eels

DESCRIPTION

Errno::AnyString allows you to place an arbitrary error message in the special $! variable, without disrupting $!'s ability to pick up the result of the next system call that sets errno.

It is useful if you are writing code that reports errors by setting $!, and none of the standard system error messages fit.

If Errno::AnyString is loaded, $! behaves as normal unless a custom error string has been set with custom_errstr. If a custom error string is set, it will be returned when $! is evaluated as a string, and 458513437 will be returned when $! is evaluated as a number, see ERRSTR_SET below.

EXPORTS

Nothing is exported by default. The following are available for export.

custom_errstr ( ERROR_STRING )

Returns a value which will set the custom error string when assigned to $!

ERRSTR_SET

ERRSTR_SET is a numeric constant with the value 458513437. This is the value that will be obtained when $! is evaluated in a numeric context while a custom error string is set.

AUTHOR

Dave Taylor, <dave.taylor.cpan at gmail.com>

BUGS AND LIMITATIONS

Please report any bugs or feature requests to bug- at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Errno::AnyString. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Errno::AnyString

You can also look for information at:

SEE ALSO

Errno, perltie

COPYRIGHT & LICENSE

Copyright 2009 Dave Taylor, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.