line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
accessors::rw - create 'classic' read/write accessor methods in caller's package. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Foo; |
8
|
|
|
|
|
|
|
use accessors::rw qw( foo bar baz ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $obj = bless {}, 'Foo'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# always return the current value, even on set: |
13
|
|
|
|
|
|
|
$obj->foo( 'hello ' ) if $obj->bar( 'world' ) eq 'world'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
print $obj->foo, $obj->bar, $obj->baz( "!\n" ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package accessors::rw; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
23095
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
22
|
1
|
|
|
1
|
|
6
|
use warnings::register; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
224
|
|
23
|
1
|
|
|
1
|
|
13
|
use base qw( accessors::classic ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
611
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '1.01'; |
26
|
|
|
|
|
|
|
our $REVISION = (split(/ /, ' $Revision: 1.3 $ '))[2]; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
6
|
use constant style => 'rw'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__END__ |