Thread Haltbarkeit von $_[0]
(9 answers)
Opened by bianca at 2010-04-02 08:36
Hi,
solange du nicht mit shift, pop etcpp. was aus @_ entfernst, ist es immer Code (perl): (dl
)
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 } man muss aber auspassen, welches @_ gemeint ist. Beispiel: Code (perl): (dl
)
1 2 3 4 5 6 7 8 sub foo4 { my ($command) = @_; my $callback = sub { my ($foo, $bar) = @_; } } das @_ innerhalb der callback-funktion, ist ein anders, als das erste @_, dass benutzt wird, um $command zu setzen hth. |