Help for this page

Select Code to Download


  1. or download this
    use l2kashe 'new';
    my $o = new;
    $o->foo( ... );
    ...
    use l2kashe;
    my $o = l2kashe->new;
    $o->foo( ... );
    
  2. or download this
    use l2kashe; # The importing new() dies
    sub new { ... } # This one stays
    # Vs
    sub new { ... } # The original new() dies
    use l2kashe; # This one overwrites
    
  3. or download this
    sub new { bless {}, shift }
    # Vs
    sub new { bless {}, __PACKAGE__}
    # or maybe even:
    sub new { bless {}, 'l2kashe' }
    
  4. or download this
    sub new {
        my $class_or_parameter = shift;
        if ( $class ne __PACKAGE__ ) {
    ...
        }
        bless { @_ }, __PACKAGE__;
    }
    
  5. or download this
    sub something {
        my $self_or_parameter = shift;
        if ( ref $self_or_parameter eq __PACKAGE__ ) {
    ...
        }
         ...
    }