Errno::AnyStringPut arbitrary strings in $! | |
Download |
Errno::AnyString Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- David Taylor
- Publisher web site:
- http://www.daes.ca/library/
Errno::AnyString Tags
Errno::AnyString Description
Put arbitrary strings in $! Errno::AnyString is a Perl module that allows you to set the error message strings that correspond to particular errno values. It makes a change to the $! magic so that the correct string is returned when errno takes a value for which a string has been registered. The change to $! is global and lasts until the Perl interpreter exits.SYNOPSISErrno::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. use Errno qw/EIO/; use Errno::AnyString qw/custom_errstr/; $! = custom_errstr "My hovercraft is full of eels"; print "$! "; # prints My hovercraft is full of eels my $saved_errno = $!; open my $fh, "< ", "/no/such/file"; print "$! "; # prints No such file or directory $! = EIO; print "$! "; # prints Input/output error $! = $saved_errno; print "$! "; # prints My hovercraft is full of eelsYou can also set the error strings for particular error numbers, for the lifetime of the Perl interpreter: use Errno::AnyString qw/register_errstr/; register_errstr "Wetware failure", 339864; $! = 339864; print "$! "; # prints Wetware failure Requirements: · Perl
Errno::AnyString Related Software