substr documentation in perldoc

A

Athanasius

Hi,

Searching perldoc (Perl 5 version 14.1) for the built-in 'substr' function
gives:
substr EXPR,OFFSET,LENGTH,REPLACEMENT
substr EXPR,OFFSET,LENGTH
substr EXPR,OFFSET

Extracts a substring out of EXPR and returns it. First character is at
offset 0 ...

Is "0" a typo for "OFFSET" -- that is, should the first sentence be: "First
character is at offset OFFSET..." -- or am I just confused?

Thanks,
Athanasius <°(((>< contra mundum
 
O

Owen

Hi,

Searching perldoc (Perl 5 version 14.1) for the built-in 'substr' function
gives:


No, that is 0, the way you count is 0,1,2, .... so the first character is at position 0. If the offset is say 3, then the string is taken from starting at the 4th character.


Owen
 
J

Jürgen Exner

Athanasius said:
Searching perldoc (Perl 5 version 14.1) for the built-in 'substr' function
gives:


Is "0" a typo for "OFFSET" -- that is, should the first sentence be: "First
character is at offset OFFSET..." -- or am I just confused?

Read that as "first character _of_the_original_string_ is at offset 0,
i.e. if you want to retrieve the first character of the original string,
then you have to use offset 0.

jue
 
A

Athanasius

Jürgen Exner" said:
Read that as "first character _of_the_original_string_ is at offset 0,
i.e. if you want to retrieve the first character of the original string,
then you have to use offset 0.

Ok, I guess that makes sense. (But, I still think this way of putting
things reads like "documentation" =~ s/document/obfusc/ ;-) .)

Thanks Jue and Owen for your prompt replies.

Athanasius <°(((>< contra mundum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top