http://qs321.pair.com?node_id=89346


in reply to writing blank array to file?

For one thing, you're adding two items to the array @chunk every time through the loop: $refnum and $scalar. So when you delete a given element, it's really going to be an item much earlier in the array. And delete just makes the value of that slot undef, it doesn't actually remove the item (see splice for that behavior)

Anyway, why bother adding the numbers to the array if they're sequential? Arrays already have sequential behavior. You can display an array with index numbers (assuming your array members have newlines) using:

my $num = 1; print map { $num++, " $_" } @myArray;

And you can delete a given index using:

foreach my $i (0..$#chunk) { print TO_WRITE $chunk[$i] unless $i == $number; }