Sponsored Content
Full Discussion: What's your drink?
The Lounge What is on Your Mind? What's your drink? Post 302127918 by blowtorch on Friday 20th of July 2007 07:09:25 AM
Old 07-20-2007
I added in 'Other' for everything else. Anyone that clicks that can specify the exact choice in a post.

Note that this is for an evening out. You don't have to put in your daily cups of tea/coffee in here! Smilie

Cheers.
 
accessors::ro(3pm)					User Contributed Perl Documentation					accessors::ro(3pm)

NAME
accessors::ro - create 'classic' read-only accessor methods in caller's package. SYNOPSIS
package Foo; use accessors::ro qw( foo bar baz ); my $obj = bless { foo => 'read only? ' }, 'Foo'; # values are read-only, so set is disabled: print "oh my! " if $obj->foo( "set?" ) eq 'read only? '; # if you really need to change the vars, # you must use direct-variable-access: $obj->{bar} = 'i need a drink '; $obj->{baz} = 'now'; # always returns the current value: print $obj->foo, $obj->bar, $obj->baz, "! "; DESCRIPTION
The accessors::ro pragma lets you create simple classic read-only accessors at compile-time. The generated methods look like this: sub foo { my $self = shift; return $self->{foo}; } They always return the current value, just like accessors::ro. PERFORMANCE
There is little-to-no performace hit when using generated accessors; in fact there is usually a performance gain. o typically 5-15% faster than hard-coded accessors (like the above example). o typically 0-15% slower than optimized accessors (less readable). o typically a small performance hit at startup (accessors are created at compile-time). o 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::classic, accessors::chained, base perl v5.12.4 2011-10-16 accessors::ro(3pm)
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy