[Israel.pm] Perl Advocacy

Gaal Yahas gaal at forum2.org
Tue Dec 28 10:52:24 PST 2004

david istermann wrote:
> And, my second comment was actually a serious one. I honestly see no
> difference between indexing something by integers or by strings. The
> array and the hash; Both have scalar values, tied to indices. Both can
> be iterated. Why separate them so brutally when essentially they serve
> the same purpose?

You are free to use a hash with numerical keys, if that's what you like.

      %harray = ( 0 => "first", 1 => "second", 2 => "third" );

I'm not familiar with PHP. Is there anything you want that you can't do
with the above construct?

(One thing springs to mind. If I had a real array, and did

      $array[10] = "eleventh";

then @array would go up to 11 automatically, with the missing elements
up to it not defined. Looking up a missing element in Perl hashes
returns undef too, but you can't trivially populate elements "up to" a
new value. You *can* use the tie interface to get this to work, though.)

In what case do you actually find this useful?


Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list