Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Is it legal to assign an array to @_ inside a subroutine? Message-ID: <1991May25.062058.3670@jpl-devvax.jpl.nasa.gov> Date: 25 May 91 06:20:58 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 30 In article marcl@ESD.3Com.COM (Marc Lavine) writes: : When I run the enclosed script (with Perl 4.003), I get the following : output: : : @a=9,8,7 : @_=9,8,7 : @a=1,2,3 : @_= : : instead of what I expected: : : @a=9,8,7 : @_=9,8,7 : @a=1,2,3 : @_=1,2,3 : : The assignment of a list to @_ seems to result in @_ becoming empty. : Is there something special about assigning to @_ inside a subroutine : or have I come across a bug? Any insights would be appreciated. As the doc said, don't do that. @_ is a little too special currently to be treated like any other array. In particular, if you assign to it, it's not smart enough to figure out that you aren't talking about function argument references any more, and it won't think it owns the pointers like a normal array does. Don't do that. Larry