in reply to Re: Action at a great distance
in thread Action at a great distance

Dude... those parentheses don't cause the array to be copied. If you want do an in-line copy like that, I recommend:
foreach (@callbacks) { $_->( @{[ @args ]} ); }
------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re: Re: Re: Action at a great distance
by Anonymous Monk on Mar 18, 2004 at 07:42 UTC
      bracket happy? :)

      $->( @{ \@args } );

      No, actually... by saying @{ \@list }, you're just referrencing and dereferrencing the same list. In order to make an inline copy of the list, you'd need to add back in there a second, new (anonymous) array.
      [me@host]$ perl -le 'sub foo { $_[0]++ } @x = (0,1); foo(@x); print "@ +x"' 1 1 [me@host]$ perl -le 'sub foo { $_[0]++ } @x = (0,1); foo(@{ \@x }); pr +int "@x"' 1 1 [me@host]$ perl -le 'sub foo { $_[0]++ } @x = (0,1); foo(@{[ @x ]}); p +rint "@x"' 0 1 [me@host]$
      Please... if you're going to "correct" someone, then make sure that you are correct and that (s)he is incorrect.
      ------------ :Wq Not an editor command: Wq