igor (ico) wrote,
igor
ico

perl

#!perl -w
package strange ;

use Data::Dumper;
use strict;
sub new {

    my $class = shift;
    my $this ={};

#    my $this = $class->SUPER::new ( @_ ); # if base class exists;
    
    $this->{ 'argv' } = [ @ARGV ] ;
    $this->{ 'isConnected' } = 'true';

    bless $this, $class;
    warn "new done";
    $this;
}
#
# main runn

sub run {

    my $this = shift;

    print Data::Dumper->Dump([ $this ],['this']);
    $this->bla({'dd'=>'ff','d' =>[1,2,3,4]}); # unknown call - pass to AUTOLOAD
    warn "run done";
    2+2;
}
#
#
sub Logout {

    my $this = shift;
    warn "logout done";
    
}
#
# running before exit
sub DESTROY {

    my $this = shift;

    $this->Logout() if ( $this->{ 'isConnected' } );
    warn "destroy done";

}

sub AUTOLOAD {

    my $this = shift;
    warn "autoload params ", Data::Dumper->Dump([@_]);
}

1;

# 
# 
package main;

    exit ( strange->new()->run() );

__END__

example oop
with init, AUTOLOAD and DESTROY 
Tags: perl
Subscribe

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments