Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!hplabs!hpl-opus!hpnmdla!chrise From: chrise@hpnmdla.HP.COM (Chris Eich) Newsgroups: comp.lang.perl Subject: Re: shift within eval gives null? Message-ID: <8310007@hpnmdla.HP.COM> Date: 15 Aug 90 19:12:13 GMT References: <8310006@hpnmdla.HP.COM> Organization: HP Network Measurements Div, Santa Rosa, CA Lines: 30 In comp.lang.perl, chrise@hpnmdla.HP.COM (Chris Eich) writes: sub main'AddToToc { # &AddToToc(); ... eval '$' . $_ . "[$FileNumber] = shift"; ... } Doesn't shift (of the subroutine arguments @_) work within an eval? After more experimenting, I've found that the eval: 1. Runs in the "main" package, so that I have to add "toc'" to my idents. 2. Runs in main-program context (so that the shift above is shifting @ARGV). Here's a line that works: eval '$toc\'' . $_ . "[$FileNumber] = shift(\@_)"; (Why is @_ available if inference (2) is true?) TFM says that eval "is executed in the context of the current perl program", which led me to write the simpler code above. I've read the description of patches 19-27, and see no change in eval's behavior. But I'd like the former, simpler code to work. Is there a good reason not to fix it? Chris