Thread problem mit lexikalischen variablen (17 answers)
Opened by kabel at 2003-08-06 01:23

pq
 2003-08-06 01:48
#59554 #59554
User since
2003-08-04
12208 Artikel
Admin1
[Homepage]
user image
hmm...
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ perl -wle'
{
  my %tags = (
      a       => \&anchor_handler,
  );
                                 
  sub dispatcher {
      my ($self, $attributes, $tagname) = @_;
      if (exists $tags{$tagname}) {
          $tags{$tagname}->($self, $attributes);
      }                                        
  }                                            
}      
sub anchor_handler { print "sub anchor_handler(@_)" }
dispatcher("self","attr","a");'
sub anchor_handler(self attr)
$

klappt doch...
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem

View full thread problem mit lexikalischen variablen