Leser: 28
1 2 3
sub foo1 { my ($command) = @_; # @_ bleibt unverändert } sub foo2 { my $command = $_[0]; # @_ bleibt unverändert } sub foo3 { my $command = shift; # @_ wird geändert }
1 2 3 4 5 6 7 8
sub foo4 { my ($command) = @_; my $callback = sub { my ($foo, $bar) = @_; } }
2010-04-02T06:36:04 biancaAls Vergleich: $1 aus einem Regex ist ja auch nur bis zum nächsten Regex haltbar und wird dann neu belegt.
Das meine ich mit der Frage.
1
2
3
4
jars@jars-desktop:~$ perl -wle 'my $var = "test"; $var =~ /.(..)/; print $1; $var =~ /noch/; print $1; $var =~ /test/; print $1'
es
es
Use of uninitialized value in print at -e line 1.
2010-04-02T09:44:00 renee$1 wird beim nächsten *erfolgreichen* Match neu gesetzt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/perl &foo; sub foo { "foo" =~ /(.*)/; print "foo 1: $1\n"; { "innerfoo" =~ /(.*)/; print "foo 2: $1\n"; } &bar; print "foo 3: $1\n"; } sub bar { "bar" =~ /(.*)/; print "bar : $1\n"; }