------------- Hauptprogramm ------------- my $container = X->new(); $GFXButton = X::GFXButton; $container->GFXButton_add($id,$app,(65*$x),(25*$i),$img,$img2,$img3, 'loslos'); }} $GFXButton->destroy_buttons($container); ------------- x.pm ------------- package X; use X::GFXButton; my $GFXButton = X::GFXButton; #Erzeugen sub new {    my ($class,@params) = @_;    my $self = {};    bless($self,$class);     $self->{BUTTS} = [];   return($self); } sub GFXButton_add {return $GFXButton->new(@_);} -------------  GFXButton.pm ------------- #Erzeugen sub new {            my ($class,@params) = @_;    my $self = {};    bless($self,$class);    #for(qw(ID APP X Y IMG IMGHV)){$self->{$_} = shift(@params);}    $self->{CONTAINER} = shift(@params);        #Container    $self->{ID} = shift(@params);    #ID oder Name    $self->{APP} = shift(@params);  #SDL APP    $self->{X} = shift(@params);    $self->{Y} = shift(@params);    $self->{IMG} = shift(@params); #IMG normal    $self->{IMGHV} = shift(@params);  #IMG hover    $self->{IMG_click} = shift(@params);            #IMG click    $self->{DOSUB} = shift(@params);    #Button's sub    $self->{TXT} = shift(@params);   #Button's Text    $self->{HV} = 0;   #Hover state    $self->draw($self->{IMG});  #Display     push( @{$self->{CONTAINER}->{BUTTS}}   ,  $self);              return($self); } #Bei MausUP Buttons normal zeichnen sub buttons_up  { my ($self, $container) = @_; for(@{$container->{BUTTS}}) {$_->{PRESSED} = 0; $_->draw($_->{IMG});} } #Buttons nicht mehr prüfen sub destroy_buttons { my ($self, $container) = @_; $container->{BUTTS} = [];}