Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: Foreach Loops

by cog (Parson)
on Mar 15, 2005 at 19:11 UTC ( #439719=note: print w/replies, xml ) Need Help??

in reply to Re: Foreach Loops
in thread Foreach Loops

And, of course, the previous line is available at $arr[$x - 1]

(unless we're talking $x == 0)

Replies are listed 'Best First'.
Re^3: Foreach Loops
by Anonymous Monk on Mar 16, 2005 at 15:19 UTC
    Well, if you consider arrays to be circular, if $x == 0, then $arr[$x - 1] is the last element. Which would be just right. Unfortunally, it doesn't work the way. $arr[$#arr + 1] isn't the same as $arr[0].

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2016-10-20 20:55 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (282 votes). Check out past polls.