init III
This commit is contained in:
41
Perl Skript template/MyClass.pm
Normal file
41
Perl Skript template/MyClass.pm
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
package MyClass;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
my $self = {
|
||||
_arg1 => shift,
|
||||
};
|
||||
# Print all the values just for clarification.
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
sub setarg1 {
|
||||
my ( $self, $arg1 ) = @_;
|
||||
$self->{_arg1} = $arg1 if defined($arg1);
|
||||
return $self->{_arg1};
|
||||
}
|
||||
|
||||
sub getarg1 {
|
||||
my( $self ) = @_;
|
||||
return $self->{_arg1};
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
#my $obj1 = new MyClass "obj1";
|
||||
#my $obj2 = MySubClass->new("obj2_1","obj2_2");
|
||||
|
||||
#print "a1:" . $obj1->getarg1() . "\n";
|
||||
#$obj1->setarg1("arg1");
|
||||
#print "a2:" . $obj1->getarg1() . "\n";
|
||||
|
||||
#print "b1:" . $obj2->getarg1() . "\n";
|
||||
#$obj2->setarg1("arg1");
|
||||
#print "b2:" . $obj2->getarg1() . "\n";
|
||||
|
||||
#print "b3:" . $obj2->getarg2() . "\n";
|
||||
#$obj2->setarg2("arg2");
|
||||
#print "b4:" . $obj2->getarg2() . "\n";
|
||||
Reference in New Issue
Block a user