Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Variable variables Message-ID: <7082@jpl-devvax.JPL.NASA.GOV> Date: 15 Feb 90 21:09:17 GMT References: <29987@sparkyfs.istc.sri.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 23 In article <29987@sparkyfs.istc.sri.com> zwicky@sparkyfs.itstd.sri.com (Elizabeth Zwicky) writes: : I have an array, @devices, consisting of a list of device names read : from the command line. For each of those devices, I need an array : consisting of the machines supposed to be backed up to that device. : What I would like to do is something like this, were this grammatical: : : foreach $device (@devices){ : @$device = something; : } : : Assuming that @devices had two strings in it, "foo" and "bar" this : should create @foo and @bar. I can do this for scalars via an : associative array (i.e., to set things up so that I can check whether : a device is free or not, I have an associative array with keys named : after the devices), but I am at a loss as to how to cope for arrays. I'd suggest foreach $device (@devices) { eval "\@$device = something"; } Larry