package news; sub AUTOLOAD { my $self=shift; my $name_of_subroutine=$AUTOLOAD; $name_of_subroutine =~ s/.*://; unless($name_of_subroutine=~m/DESTROY/) { print "get from $name_of_subroutine $self->{$name_of_subroutine} \n"; } } sub new { my $class=shift; my $self={}; bless $self,$class; $self->{get_from_bbc}='www.bbc.com'; $self->{get_from_voanews}='www.voanews.com'; return $self; } package main; my $n=news->new(); $n->get_from_bbc(); $n->get_from_voanews(); output: get from get_from_bbc www.bbc.com get from get_from_voanews www.voanews.com