Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: writing blank array to file?

by bikeNomad (Priest)
on Jun 18, 2001 at 20:09 UTC ( #89346=note: print w/replies, xml ) Need Help??

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; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://89346]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2022-01-29 05:36 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (74 votes). Check out past polls.