1accessors::rw(3) User Contributed Perl Documentation accessors::rw(3)
2
3
4
6 accessors::rw - create 'classic' read/write accessor methods in
7 caller's package.
8
10 package Foo;
11 use accessors::rw qw( foo bar baz );
12
13 my $obj = bless {}, 'Foo';
14
15 # always return the current value, even on set:
16 $obj->foo( 'hello ' ) if $obj->bar( 'world' ) eq 'world';
17
18 print $obj->foo, $obj->bar, $obj->baz( "!\n" );
19
21 The accessors::rw pragma lets you create simple classic read/write
22 accessors at compile-time. It is an alias for accessors::classic.
23
25 Steve Purkis <spurkis@cpan.org>.
26
28 accessors, accessors::ro, accessors::classic, accessors::chained, base
29
30
31
32perl v5.32.0 2020-07-28 accessors::rw(3)