Thread sub in Variable ohne & (3 answers)
Opened by bianca at 2013-12-01 09:02

bianca
 2013-12-01 09:02
#172341 #172341
User since
2009-09-13
6987 Artikel
BenutzerIn

user image
Kurze Verständnisfrage: Wieso bringt das folgende Script ohne Verwendung des Kaufmannsund beim Aufruf im oberen Teil einen Syntax error? Im unteren Teil hingegen geht es ohne Kaufmannsund. Wieso?
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
#---------------
my $lokal_config = sub { my ($c) = @_; $c->{foo}='bar'; };
my %lokal;
&$lokal_config(\%lokal);
say keys %lokal;
#---------------
my %test = (foo => sub { my ($c) = @_; $c->{foo2}='bar'; });
my %lokal2;
$test{foo}(\%lokal2);
say keys %lokal2;
10 print "Hallo"
20 goto 10

View full thread sub in Variable ohne &