accessors::classic man page on Pidora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Pidora logo
[printable version]

accessors::classic(3) User Contributed Perl Documentationaccessors::classic(3)

NAME
       accessors::classic - create 'classic' read/write accessor methods in
       caller's package.

SYNOPSIS
	 package Foo;
	 use accessors::classic qw( foo bar baz );

	 my $obj = bless {}, 'Foo';

	 # always return the current value, even on set:
	 $obj->foo( 'hello ' ) if $obj->bar( 'world' ) eq 'world';

	 print $obj->foo, $obj->bar, $obj->baz( "!\n" );

DESCRIPTION
       The accessors::classic pragma lets you create simple classic Perl
       accessors at compile-time.

       The generated methods look like this:

	 sub foo {
	     my $self = shift;
	     $self->{foo} = shift if (@_);
	     return $self->{foo};
	 }

       They always return the current value.

       Note that there is no dash ("-") prepended to the property name as
       there are in accessors.	This is for backwards compatability.

PERFORMANCE
       There is little-to-no performace hit when using generated accessors; in
       fact there is usually a performance gain.

       ·   typically 5-15% faster than hard-coded accessors (like the above
	   example).

       ·   typically 1-15% slower than optimized accessors (less readable).

       ·   typically a small performance hit at startup (accessors are created
	   at compile-time).

       ·   uses the same anonymous sub to reduce memory consumption (sometimes
	   by 80%).

       See the benchmark tests included with this distribution for more
       details.

CAVEATS
       Classes using blessed scalarrefs, arrayrefs, etc. are not supported for
       sake of simplicity.  Only hashrefs are supported.

AUTHOR
       Steve Purkis <spurkis@cpan.org>

SEE ALSO
       accessors, accessors::rw, accessors::ro, accessors::chained, base

perl v5.14.1			  2011-06-20		 accessors::classic(3)
[top]

List of man pages available for Pidora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net