This may seem a stupid question but one of the Monastery's quotes say that "A stupid question is a question not asked."
Having said that, I'm working on making Perl my preferred programming language. Right now, I'm an accomplished C programmer but I want some change... whatever, back to the point.
my @arr = (
"hello to humans",
"of planet Earth.",
my @new = (
"I am here to annihilate you all so",
"please co-operate. It is in accordance with the Galactic council.
splice(@arr, scalar(@arr), 0, @new);
the "splice" line is essentially push(@arr, @new)
right? From C perspective, it is basically strcpy(arr, new)
where "arr" and "new" are C arrays.
Again from a C perspective, let *(arr + n) (for some n) point to the location past the last entry of array "arr". If I say strcpy((arr + n), new) I'll get a seg fault (obviously!). But when I do splice(@arr, scalar(@arr), n, @new) I do not get the seg fault.
Why I think it should seg fault?
Simple, scalar(@arr) takes me to the last position in the array "arr" and the third argument to splice is the length. Now, my length is exceeding the length of the array "arr" hence I'm trying to access the something out of bounds, therefore it should seg fault.
Whats the story, morning glory?!