NAME

autocroak - Replace functions with ones that succeed or die with lexical scope

VERSION

version 0.008

SYNOPSIS

use autocroak;

open(my $fh, '<', $filename); # No need to check!
print "Hello World"; # No need to check either

DESCRIPTION

The autocroak pragma provides a convenient way to replace functions that normally return false on failure with equivalents that throw an exception on failure.

The autocroak pragma has lexical scope, meaning that functions and subroutines altered with autocroak will only change their behaviour until the end of the enclosing block, file, or eval.

Optionally you can pass it an allow hash listing errors that are allowed for certain op:

use autocroak allow => { unlink => ENOENT };

Note: This is an early release, the exception messages as well as types may change in the future, do not depend on this yet.

Supported keywords:

  • open

  • sysopen

  • close

  • system

  • print

  • flock

  • truncate

  • exec

  • fork

  • fcntl

  • binmode

  • ioctl

  • pipe

  • kill

  • bind

  • connect

  • listen

  • setsockopt

  • accept

  • getsockopt

  • shutdown

  • sockpair

  • read

  • recv

  • sysread

  • syswrite

  • stat

  • chdir

  • chown

  • chroot

  • unlink

  • chmod

  • utime

  • rename

  • link

  • symlink

  • readlink

  • mkdir

  • rmdir

  • opendir

  • closedir

  • select

  • dbmopen

  • dbmclose

  • gethostbyaddr

  • getnetbyaddr

  • msgctl

  • msgget

  • msgrcv

  • msgsnd

  • semctl

  • semget

  • semop

  • shmctl

  • shmget

  • shmread

  • -R

  • -W

  • -X

  • -r

  • -w

  • -x

  • -e

  • -s

  • -M

  • -C

  • -A

  • -O

  • -o

  • -z

  • -S

  • -c

  • -b

  • -f

  • -d

  • -p

  • -u

  • -g

  • -k

  • -l

  • -t

  • -T

  • -B

AUTHOR

Leon Timmermans <leont@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Leon Timmermans.

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