in reply to Ignoring values in a hash slice assignment

What about using an array list slice on your hash slice?
my @fields = ( 'FIRSTNAME', 'LASTNAME', 'PHONE', 'FAX', 'CITY', 'STATE', );
and then
@record{@fields} = (split(/\t/, $_))[0,1,2,6,8,9];
UPDATE: thx to converter for pointing out my goof-up

grep
grep> grep clue /home/users/*

Replies are listed 'Best First'.
Re: Re: Ignoring values in a hash slice assignment
by impossiblerobot (Deacon) on Feb 28, 2002 at 22:06 UTC
    Thanks, grep (and dragonchild who made a similar suggestion).

    Using an array slice on the split was one of the other ways I considered, but my actual field list is much longer (over 70 fields in all), and I didn't want to maintain two long lists.

    I could generate the second list programmatically, but I figured that would be even more complicated that my two solutions. (Of course, it is very possible that I was wrong.)

    Impossible Robot
      Actually I was going to add 'creating the list programmatically' as an additional suggestion. The great thing is, if you do it right, your data structure is factored out to 1 place, so you only have to make changes in 1 place as you make changes. I think if you follow this you'll be happier in the long run.

      grep
      grep> grep clue /home/users/*