in reply to Re: Build your array with push
in thread Build your array with push

I don't like the push way of constructing arrays.

You think that's bad, I once had to maintain a program that did this:

my @array; $array[$#array] = "Hibbs"; $array[$#array] = "Daglish"; $array[$#array] = "Schwartz"; $array[$#array] = "Vroom"; ...
And so on for about 30 lines.

One of the few times I felt justified in regexing some code.

Replies are listed 'Best First'.
Re^3: Build your array with push
by Roy Johnson (Monsignor) on Jan 31, 2006 at 20:26 UTC
    Woah, woah, woah. That code just replaces the last element multiple times. Did you maybe mean
    $array[@array] = "Hibbs";
    or
    $array[++$#array] = "Hibbs";
    ?

    Caution: Contents may have been coded under pressure.
      Nope, I meant what I said, believe it or not. The program never worked correctly, and that was one of many reasons why. (No strict, either.) Amazingly, this one dude had been working on it for six weeks before I saw it.