In case you want to re-implement Perl arrays, The Daily WTF shows you how.
Seriously though, a former colleague of mine had a better horror story. It went something like this:
Now, if you think that's heinous, imaging copying and pasting this chunk of code in each of the few dozen times you need to add an element at the end of an array. In a script that's thousands of lines long.$index = "";
$element_count = $#array + 1;
open(TEMP, ">temp.file");
for( $index = 0; $index < $element_count; $i++) {
print TEMP $array[$index];
print TEMP "\n";
}
print TEMP $new_value_1;
print TEMP "\n";
print TEMP $new_value_2;
print TEMP "\n";
close(TEMP);
@array = ();
open(TEMP, "temp.file");
$index = 0;
while(<TEMP>) {
$array[$index] = $_;
$index = $index + 1;
}
close(TEMP);