|< 1 2 >| | 16 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
load(@_, $self) if @_;
return $self;
}
sub load {
my $self = shift;
if (@_) {
print "@_\n"; #Community::Storage=HASH(0x81717c8)
for (keys %{@_}) {
# wird leider nicht durchlaufen
$self->{$_} = $_[0]->{$_};
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
load($_[0], $self);
return $self;
}
sub load {
my ($args, $self) = shift;
if ($args) {
for (keys %{$args}) {
print "$_\n";
}
}
}
1
2
3
4
5
6
7
8
#!/usr/bin/perl
use strict;
use Community::Storage;
my $obj = Community::Storage->new({name => 'Hans Peter'});
print $obj->param('name'),"\n";
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
package Community::Storage;
use strict;
our $VERSION = '1.0';
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
load($_[0], $self) if @_;
return $self;
}
sub load { # hashref auslesen und speichern
my ($args, $self) = @_;
if ($args) {
for (keys %{$args}) {
$self->{$_} = $args->{$_};
}
}
}
sub param { # wert zurückliefern
my $self = shift;
return $self->{@_};
}
sub add { # neue Daten aufnehmen
my $self = shift;
my ($name, $value) = @_;
$self->{$name} = $value;
}
1;
load(@_, $self) if @_;
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
package Community::Storage;
use strict;
use Data::Dumper qw/Dumper/;
our $VERSION = '1.0';
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
$self->init($self, @_);
return $self;
}
sub init {
my $self = shift;
print Dumper \@_;
if (@_) {
for (keys %{@_}) {
$self->{$_} = $_[0]->{$_};
}
}
}
sub param {
my $self = shift;
return $self->{@_};
}
sub add {
my $self = shift;
my ($name, $value) = @_;
$self->{$name} = $value;
}
1;
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
package Community::Storage;
use strict;
use Data::Dumper qw/Dumper/;
our $VERSION = '1.0';
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
$self->init(@_);
return $self;
}
sub init {
my $self = shift;
if (@_) {
for (keys %{@_}) {
$self->{$_} = $_[0]->{$_};
}
}
}
sub param {
my $self = shift;
return $self->{$_[0]};
}
sub add {
my $self = shift;
my ($name, $value) = @_;
$self->{$name} = $value;
}
sub update {
my $self = shift;
$self->{$_[0]} = $_[1];
}
sub delete {
my $self = shift;
delete($self->{$_[0]});
}
1;
|< 1 2 >| | 16 Einträge, 2 Seiten |