#!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