Class::MethodMaker::scalar man page on Scientific

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

Class::MethodMaker::scUser(Contributed Perl DocumClass::MethodMaker::scalar(3)

NAME
       Class::Method::scalar - Create methods for handling a scalar value.

SYNOPSIS
	 package MyClass;
	 use Class::MethodMaker
	   [ scalar => [qw/ a -static s /]];

	 sub new {
	   my $class = shift;
	   bless {}, $class;
	 }

	 package main;

	 my $m = MyClass->new;
	 my $a, $x;

	 $a = $m->a;	   # *undef*
	 $x = $m->a_isset; # false
	 $a = $m->a(1);	   # 1
	 $m->a(3);
	 $x = $m->a_isset; # true
	 $a = $m->a;	   # 3
	 $a = $m->a(5);	    # 5;
	 $m->a_reset;
	 $x = $m->a_isset; # false

DESCRIPTION
       Creates methods to handle array values in an object.  For a component
       named "x", by default creates methods "x", "x_reset", "x_isset",
       "x_clear".

       Methods available are:

       "*"

	 $m->a(3);
	 $a = $m->a;	   # 3
	 $a = $m->a(5);	    # 5;

       Created by default.  If an argument is provided, the component is set
       to that value.  The method returns the value of the component (after
       assignment to a provided value, if appropriate).

       *_reset

	 $m->a_reset;

       Created by default.  Resets the component back to its default.
       Normally, this means that *_isset will return false, and "*" will
       return undef.  If "-default" is in effect, then the component will be
       set to the default value, and *_isset will return true.	If
       "-default_ctor" is in effect, then the default subr will be invoked,
       and its return value used to set the value of the component, and
       *_isset will return true.

       Advanced Note: actually, defaults are assigned as needed: typically,
       the next time a the value of a component is read.

       *_isset

	 print $m->a_isset ? "true" : "false";

       Created by default.  Whether the component is currently set.  This is
       different from being defined; initially, the component is not set (and
       if read, will return undef); it can be set to undef (which is a set
       value, which also returns undef).  Having been set, the only way to
       unset the component is with <*_reset>.

       If a default value is in effect, then <*_isset> will always return
       true.

       *_clear

	 $m->a(5);
	 $a = $m->a;	   # 5
	 $x = $m->a_isset; # true
	 $m->a_clear;
	 $a = $m->a;	   # *undef*
	 $x = $m->a_isset; # true

       Created by default.  A shorthand for setting to undef.  Note that the
       component will be set to undef, not reset, so *_isset will return true.

       *_get

	 package MyClass;
	 use Class::MethodMaker
	   [ scalar => [{'*_get' => '*_get'}, 'a'],
	     new    => new, ];

	 package main;
	 my $m = MyClass->new;
	 $m->a(3);
	 $a = $m->a_get;     # 3
	 $a = $m->a_get(5);  # 3; ignores argument
	 $a = $m->a_get(5);  # 3; unchanged by previous call

       Created on request.  Retrieves the value of the component without
       setting (ignores any arguments passed).

       *_set

	 package MyClass;
	 use Class::MethodMaker
	   [ scalar => [{'*_set' => '*_set'}, 'a'],
	     new    => new, ];

	 package main;
	 my $m = MyClass->new;
	 $m->a(3);
	 $a = $m->a_set;     # *undef*
	 $a = $m->a_set(5);  # *undef*; value is set but not returned
	 $a = $m->a;	     # 5

       Created on request.  Sets the component to the first argument (or undef
       if no argument provided).  Returns no value.

perl v5.10.1			  2011-05-31	 Class::MethodMaker::scalar(3)
[top]

List of man pages available for Scientific

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