in reply to Using Variable Value as Variable Name

Plus, there's always the series of three posts by Mark-Jason Dominus on Why it's stupid to `use a variable as a variable name'

  • Comment on Re: Using Variable Value as Variable Name

Replies are listed 'Best First'.
Re^2: Using Variable Value as Variable Name
by umama (Initiate) on Jun 28, 2012 at 14:21 UTC

    Thanks to all for the info. I'm an new to Perl, and was able to do this in PHP. I'm new to PHP as well. I'm an old Cobol/SAS programmer, and I think I have a long way to go. :-)

Re^2: Using Variable Value as Variable Name
by umama (Initiate) on Jun 28, 2012 at 14:25 UTC
    Additional info... my reason for doing this is that I'm processing text files for loading to a database and the column order can vary by file.
      A hash is a much more natural way of dealing with this, and IMHO one of Perl's greatest strengths (the other being regular expressions). You could even use lock_keys from Hash::Util to protect yourself from typos.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re^2: Using Variable Value as Variable Name
by Anonymous Monk on Jun 28, 2012 at 14:04 UTC

    Boy, either I am a slow typer, or the responses come really quick here. Didn't mean to post a duplicate link.