in reply to Ignoring values in a hash slice assignment

An update:

After working through the great responses I got, and testing various options, here's where I am:

Thanks to everyone who I haven't thanked yet (petral and seattlejohn) and I'm still open to more suggestions. :-)

Impossible Robot
  • Comment on Re: Ignoring values in a hash slice assignment

Replies are listed 'Best First'.
Re2: Ignoring values in a hash slice assignment
by dragonchild (Archbishop) on Mar 01, 2002 at 17:45 UTC
    Ok. You're just not thinking it through. You say that you have a list of some 70 fields, some of which may be needed and others not. Given how you presented your original question, you're storing this list of fieldnames in an array, putting 'DUMMY' for the fields you wish to ignore.

    That, my friend, is a maintainer's nightmare.

    1. You don't ever say what the field is you're ignoring
    2. You don't say WHY you're ignoring that field
    3. It isn't easy to change which fields you're ignoring without researching into what fields exist
    4. It also isn't easy to change which order the fields exist in.

    So, we need some way of abstracting out which fields are there. Then, we need a way of identifying which fields we actually want. Lastly, we need a way of making sure that this information (which will become quite large) doesn't impact our main program.

    Enter "Modular Design". Let's create a module where we store some data about what fields we want. Let's also create a few functions that allow us to talk about various aspects (or attributes) of each field.

    Now, you don't need a full-blown OO implementation of this. That would be too much work and too unwieldy to manage. However, you can do a very nice Exporter implementation of this. Something along the lines of: