Thread Probleme mit anonymen subs (13 answers)
Opened by Ronnie at 2005-03-10 09:25

kabel
 2005-03-10 11:31
#52498 #52498
User since
2003-08-04
704 Artikel
BenutzerIn
[default_avatar]
spassiger wirds wenn du alles in eine sub packst:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
my $substitute= sub { $_; };
for (<DATA>) {
        chomp;
        my ($k, $v) = split(/ -- /);
        print "adding correction for [$k]\n";
        $substitute= sub { my $r= shift; sub { s/^$k/$v/ or $r->() } }->( $substitute );
}

while(<>) {
        chomp;
        $substitute->();
        print $_, $/;
}
-- stefan

View full thread Probleme mit anonymen subs