Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Inserting into an array while stepping through it

by Anonymous Monk
on Jun 13, 2003 at 12:22 UTC ( [id://265656]=note: print w/replies, xml ) Need Help??


in reply to Re: Inserting into an array while stepping through it
in thread Inserting into an array while stepping through it

That works fine, Bob.

I was hoping to avoid using an index. I'm of the school of thought that the fewer variables a program has - especially global variables, see http://c2.com/cgi/wiki?GlobalVariablesAreBad - the easier it is to understand and maintain.

Still, this gets me over that hurdle ;-)

  • Comment on Re: Re: Inserting into an array while stepping through it

Replies are listed 'Best First'.
Re: Re: Re: Inserting into an array while stepping through it
by zakb (Pilgrim) on Jun 13, 2003 at 14:11 UTC

    I just wanted to point out that the index ($i) does not have to be global. You could write:

    while (my $i < @a)

    ... and have $i scoped to the while loop. Check out Lexical scoping like a fox.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found