Richard Lee wrote:
Rob Dixon wrote:

Perhaps it would help to think of the offset as being the index of the
points between the characters, so the start of the string is at offset
zero, after 'a' (and before 'b') is at offset one and so on. Then can
you see how offset 7 is before 'hi' and offset 9 is after it?

HTH,

Rob

No  sorry, I do not understand

0 1  2 3  4  5  6  7   8  9
a  b c  d  e  f   h   i    j   k

I don't understand how offset 7 is before hi(when it's actually start of the hi). I am begining to think that defintion of 7 and 9 came from the formula substr $var , 7,2 because the position is at 7th and it needs 2 characters..(7+2)
I don't understand where this offset concept came from..

Your table above is a bit mangled. Look:

                    1                   2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|

So 'hi' falls between 7 and 9. OK?

Another way. Count the characters from the beginning of the string: how
many characters up to the start of the match. Count again: how many up
to the end of the match?

Perhaps this is bit beyond my programming skills at this time..  :-(

We're here to help you fix precisely that. It's also an important
concept to grasp, as it relates to array indices and all sorts of
comparable stuff.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to