Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: •Re: array index -1 oddity

by scain (Curate)
on Dec 06, 2002 at 19:07 UTC ( #218129=note: print w/ replies, xml ) Need Help??

in reply to •Re: array index -1 oddity
in thread array index -1 oddity

Really? That strikes me as a little odd and counter-intuitive. There are instances where having an array index of -1 (or -2 or -3) are quite useful. In particular, some numerical methods come to mind. I suppose that if I felt like doing that, I would need to modify a magic variable first? Like $[ if I read man perlvar correctly.

Project coordinator of the Generic Model Organism Database Project

Comment on Re: •Re: array index -1 oddity
Replies are listed 'Best First'.
•Re: Re: •Re: array index -1 oddity
by merlyn (Sage) on Dec 06, 2002 at 20:01 UTC
    Maybe you missed this statement in perldata:
      Variable names
        Perl has three built-in data types: scalars, arrays of scalars, and
        associative arrays of scalars, known as "hashes". Normal arrays are
        ordered lists of scalars indexed by number, starting with 0 and with
        negative subscripts counting from the end. Hashes are unordered
        collections of scalar values indexed by their associated string key.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2015-11-26 01:01 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (695 votes), past polls