Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
self::init(3)	      User Contributed Perl Documentation	 self::init(3)

NAME
       self::init - Invoke package init	methods	at compile time

VERSION
       Version 0.01

SYNOPSIS
	   # At	compile	time
	   use self::init
	       \-x => qw( y z ), # same	as BEGIN { CLASS->x('y','z'); }
	   ;

	   # At	runtime
	   self::init
	       \-a => qw(a b),
	       \-b => (),
	       \-c => qw( c c ),
	   ;

	   # Same as
	   CLASS->a('a','v');
	   CLASS->b();
	   CLASS->c('c','c');

	   # With bad arguments	(scalarrefs, containing	string,	beginning from -)
	   self::init
	       [ a => \'-arg1',	\'-arg2' ],
	       [ b => 'arg3', 'arg4' ],
	   ;

	   # ! Warning!
	   # Mixed syntax is not allowed
	   self::init
	       \-a => qw(arg1 arg2),
	       [ b => \'-arg1',	\'-arg2' ],
	   ;

	   # will be invoked as

	   CLASS->a('arg1','arg2', [ 'b', \'-arg1', \'-arg2' ] );

	   # So	be aware

DESCRIPTION
       This module is just a helper to avoid repetiotion of ugly
       __PACKAGE__->method();

INTERFACE
       self::init pragma
	       use self::init ARGS;

       self::init statement
	       self::init ARGS;

       ARGS
	   Synopsis 1:

	   Method name is constructed as a reference to	string,	containing
	   method name,	prefixed with '-'.  Rest in list is threated as
	   arguments to	that method, until next	method name or end of whole
	   statement.  So, if your arguments not written by hand or in some
	   way could receive value of SCALARREF, containing string, beginning
	   from	-, invocation will be wrong (see Synopsis 2)

	   When	writing	method names not quoted	(hash key bareword), the whole
	   statement looks like	an ASCII tree, where methods are descendants
	   of self::init ;)

	       self::init
		   \-method1 =>	(1,2,3),
		   \-method_another => ('some',	'args'),
		   \-_private_method =>	(), # no args,
		   # so	on
	       ;

	   Synopsis 2:

	   Single method invocation is constructed as ARRAYREF,	containing
	   first element as method name	and rest as arguments.	It is reliable
	   to any arguments, but don't mix both	synopsises in a	single call

	       self::init
		   [ method1 =>	1,2,3 ],
		   [ method_another => 'some', 'args' ],
		   [ _private_method =>	(), ],	# no args
		   # so	on
	       ;

AUTHOR
       Mons Anderson, <mons@cpan.org>

BUGS
       None known

COPYRIGHT & LICENSE
       Copyright 2009 Mons Anderson.

       This program is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

perl v5.24.1			  2009-05-19			 self::init(3)

NAME | VERSION | SYNOPSIS | DESCRIPTION | INTERFACE | AUTHOR | BUGS | COPYRIGHT & LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=self::init&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help