GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  SELF::INIT (3)

.ds Aq ’

NAME

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

CONTENTS

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 SELF::INIT (3) 2009-05-19

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.