[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

(very OT now) Re: going OT: moving to perl



On Sat, Jul 06, 2002 at 11:29:40PM -0100, andrej hocevar wrote:
| Frankly, it's just a quick question: in perl, is there a way of
| doing something like ${var:x:y}, x and y being numbers, the starting
| point and the lenght to be printed?

Just in case someone cares, since I don't know perl, in python it
would be written as

    var[x:y]

and is called a "slice".  The same can be done with other sequence
types such as lists and tuples.  If you use only one index (and no
':') then it is a simple indexing like an array in C.  Either endpoint
can be omitted in which case the sequence's boundary is assumed.  If
either index is negative, it counts from the other end of the
sequences.

-D

-- 

In the way of righteousness there is life;
along that path is immortality.
        Proverbs 12:28
 
http://dman.ddts.net/~dman/

Attachment: pgpZ5bJOKW03w.pgp
Description: PGP signature


Reply to: