in reply to What defines the choice of a Hash or an Array?

How do you know which one to use and when?
If you know the difference between an array and a hash, you'll know when to use which.

`perldoc perldata'

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

  • Comment on Re: What defines the choice of a Hash or an Array?

Replies are listed 'Best First'.
Re^2: What defines the choice of a Hash or an Array?
by ghenry (Vicar) on Mar 31, 2005 at 07:56 UTC

    I do know the difference, but you could use an array, as it's ordered, and, for the same thing, you could just use a hash and then sort it.

    I wanted to hear from people on their preference and I thought that there might be a performance issue etc.

    But thanks for the links.

    Walking the road to enlightenment... I found a penguin and a camel on the way..... Fancy a yourname@perl.me.uk? Just ask!!!
      I do know the difference, but you could use an array, as it's ordered, and, for the same thing, you could just use a hash and then sort it.
      Say you live a city next to an airport, and you want to visit a friend who lives 20 miles away at the other end of city also next to an airport, do you fly or do you drive?

      Use a hash when it benefits you to do so, not just because you can.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        Fair enough.

        Walking the road to enlightenment... I found a penguin and a camel on the way..... Fancy a yourname@perl.me.uk? Just ask!!!