Is there a way to push values into a negative array?
Lets say I'm doing something like this...
my @arr;
push (@arr, "one");
push (@arr, "two");
push (@arr, "three");
$arr[-1] = "neg_one";
$arr[-2] = "neg_two";
$arr[-3] = "neg_three";
for (my $a=-3;$a<@arr;$a++){
print "Array[".$a."]::".$arr[$a]."\n";
}
# Return
Array[-3]::neg_three
Array[-2]::neg_two
Array[-1]::neg_one
Array[0]::neg_three
Array[1]::neg_two
Array[2]::neg_one
print "Array length: ".@arr."\n";
# Returns 3
So, can you not map a value to a negative index in an array? Seemed to make sense to me that if I wanted to say, plot a value to the left of something, putting it into a negative array would do the trick. So what's the big deal? Am I doing it wrong or is this a very bad practice for reasons I haven't considered?
Thoughts?