Thread "Hello World" objektorientiert (28 answers)
Opened by renee at 2006-04-12 19:38

master
 2006-04-12 20:03
#64808 #64808
User since
2003-10-20
610 Artikel
BenutzerIn
[default_avatar]
Als Beispiel.... :-)

Skript:
Code: (dl )
1
2
3
4
5
use HelloWorld;

my $greeting = HelloWorld->new();
$greeting->set('text', 'Hello World');
$greeting->say($greeting->get('text'));


HelloWorld.pm
Code: (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
package HelloWorld;

use strict;
use warnings;
use lib qw(.);
use Greetings ($0);
use String;



#Erzeugen
sub new {
   my ($class,@params) = @_;
   my $self = {};
  bless($self,$class);
 return($self);
}

sub set
{
my ($self,$var, $value ) = @_;
$self->{$var} = $value;
}

sub get
{
my ($self,$var) = @_;
return $self->{$var};
}



sub say
{
my ($self,$value) = @_;
print $value;
}

#alternativ
sub say2
{
my ($self,$value) = @_;
print $self->{text};
}
\n\n

<!--EDIT|master|1144857956-->
$i='re5tsFam ^l\rep';$i=~s/[^a-z| ]//g;$\= reverse "\U!$i";print;

View full thread "Hello World" objektorientiert