… | |
… | |
3 | AnyEvent::Strict - force strict mode on for the whole process |
3 | AnyEvent::Strict - force strict mode on for the whole process |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use AnyEvent::Strict; |
7 | use AnyEvent::Strict; |
8 | # struct mode now switched on |
8 | # strict mode now switched on |
9 | |
9 | |
10 | =head1 DESCRIPTION |
10 | =head1 DESCRIPTION |
11 | |
11 | |
12 | This module implements AnyEvent's strict mode. |
12 | This module implements AnyEvent's strict mode. |
13 | |
13 | |
14 | Loading it makes AnyEvent check all arguments to AnyEvent-methods, at the |
14 | Loading it makes AnyEvent check all arguments to AnyEvent-methods, at the |
15 | expense of being slower (often the argument checking takes longer than the |
15 | expense of being slower (often the argument checking takes longer than the |
16 | actual fucntion). |
16 | actual function). |
17 | |
17 | |
18 | Normally, you don't load this module yourself but instead use it |
18 | Normally, you don't load this module yourself but instead use it |
19 | indirectly via the C<PERL_ANYEVENT_STRICT> environment variable (see |
19 | indirectly via the C<PERL_ANYEVENT_STRICT> environment variable (see |
20 | L<AnyEvent>). However, this module can be loaded at any time. |
20 | L<AnyEvent>). However, this module can be loaded at any time. |
21 | |
21 | |
22 | =cut |
22 | =cut |
23 | |
23 | |
24 | package AnyEvent::Strict; |
24 | package AnyEvent::Strict; |
|
|
25 | |
|
|
26 | no warnings; # *sigh* |
25 | |
27 | |
26 | use Carp qw(croak); |
28 | use Carp qw(croak); |
27 | |
29 | |
28 | use AnyEvent (); |
30 | use AnyEvent (); |
29 | |
31 | |
… | |
… | |
43 | or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; |
45 | or croak "AnyEvent->io called with illegal cb argument '$arg{cb}'"; |
44 | delete $arg{cb}; |
46 | delete $arg{cb}; |
45 | |
47 | |
46 | defined fileno $arg{fh} |
48 | defined fileno $arg{fh} |
47 | or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; |
49 | or croak "AnyEvent->io called with illegal fh argument '$arg{fh}'"; |
|
|
50 | -f $arg{fh} |
|
|
51 | and croak "AnyEvent->io called with fh argument pointing to a file"; |
48 | delete $arg{fh}; |
52 | delete $arg{fh}; |
49 | |
53 | |
50 | $arg{poll} =~ /^[rw]$/ |
54 | $arg{poll} =~ /^[rw]$/ |
51 | or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; |
55 | or croak "AnyEvent->io called with illegal poll argument '$arg{poll}'"; |
52 | delete $arg{poll}; |
56 | delete $arg{poll}; |