Thread bless-Frage
(13 answers)
Opened by Froschpopo at 2007-12-09 13:43
Warum nicht so?
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 #!/usr/bin/perl use strict; use warnings; ####################################################### package MyModul; sub new { my $class = shift; my $self = {}; bless($self, $class); return $self; } sub search { my $self = shift; my $name = shift; return MyModul::Search->new($name); } 1; ####################################################### package MyModul::Search; use base 'MyModul'; sub new { my $class = shift; my $name = shift; my $self = {'_NAME_'=>$name}; bless($self, $class); return $self; } sub get { my $self=shift; return $self->{'_NAME_'}; } 1; ####################################################### package main; my $test=MyModul->new(); my $name_a=$test->search('NAME1'); print $name_a->get()."\n"; |