[comp.lang.perl] surprize ?

henkp@ruuinf.cs.ruu.nl (Henk P. Penning) (01/19/90)

Why does the following script produce no output ?

sub ttt {
  @_ = ('aap','noot') ;
  print @_ ;
}

do ttt('x','y') ;

-- 
Henk P. Penning, Dept of Computer Science, Utrecht University.
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31-30-534106
e-mail   : henkp@cs.ruu.nl (uucp to hp4nl!ruuinf!henkp)

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (01/23/90)

In article <2307@ruuinf.cs.ruu.nl> henkp@ruuinf.cs.ruu.nl (Henk P. Penning) writes:
: Why does the following script produce no output ?
: 
: sub ttt {
:   @_ = ('aap','noot') ;
:   print @_ ;
: }
: 
: do ttt('x','y') ;

Because @_ is the funny array used to pass arguments in, and there's a
bug in trying to get it to behave like a normal array when you assign to
it.  One of these days I'll fix it, but for now use a different array.

Larry