Thread Filehandle lokal benutzen
(5 answers)
Opened by Schwammkopf at 2012-04-26 19:28
Innerhalb eines Blocks:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 my $HENDL = 'BLAH'; { say "Entering Chicken4Free"; my $HENDL; # now the Chicken handler is local - may be it's called FeilHändl in Bavaria open ($HENDL, "<", "wiener.wald") or die "No Chicken found at Chicken4Free!"; # hunt the chicken my $meal; while ($meal = <$HENDL> ) { # get some chicken pieces chop($meal); # eat something } close($HENDL) or die "Oh! Chicken is living!?"; # call the waiter and leave } say "Back on the street!"; say "Now \$HENDL is always $HENDL"; PS: Hähnchenjagd ohne Gewehr! Last edited: 2012-04-26 20:12:16 +0200 (CEST) |