Thread Routinen erzeugen (18 answers)
Opened by bloonix at 2007-01-30 16:53

bloonix
 2007-01-30 16:53
#73841 #73841
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Hallo Community,

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
sub foo {
my $self = shift;
return $self->foobar('foo', @_);
}

sub bar {
my $self = shift;
return $self->foobar('bar', @_);
}

sub foobar {
return 1;
}


wie kann ich die Routinen &foo und &bar in einer Schleife erzeugen?
Ist sowas überhaupt möglich?

Beispiel:

Code: (dl )
1
2
3
for (qw(foo bar)) {
*{"$_"} = sub { my $self = shift; $self->foobar("$_", @_); };
}


Das klappt natürlich so nicht.

Gruss,
opi
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Routinen erzeugen