Thread Module: Objekte voneinander trennen? (8 answers)
Opened by Froschpopo at 2010-02-19 15:29

esskar
 2010-02-19 16:20
#133320 #133320
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package MyModules::Test;
use base qw(Class::Accessor);

use strict;
use warnings;

__PACKAGE__->mk_accessors(qw(farbe));

sub create {
   my $self = shift;    
   my $args = shift || {};
   $self->new($args);
}

1;


Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl

use strict;
use warnings;
use MyModules::Test;

my $obj = MyModules::Test->new;

my $farbe_1 = $obj->create({farbe => 'rot'});
my $farbe_2 = $obj->create({farbe => 'blau'});

print $farbe_2->farbe;
print $farbe_1->farbe;


so vielleicht? nicht getestet!

View full thread Module: Objekte voneinander trennen?