Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Syntactic Confectionery Delight
 
PerlMonks  

index offset mean?

by dicty (Sexton)
on Jan 18, 2013 at 16:20 UTC ( #1014081=perlquestion: print w/ replies, xml ) Need Help??
dicty has asked for the wisdom of the Perl Monks concerning the following question:

What's the meaning of index offset?

Thanks a lot!

Dicty

Comment on index offset mean?
Re: index offset mean?
by Athanasius (Prior) on Jan 18, 2013 at 16:33 UTC

    Perhaps the following entry from the Camel Book Glossary will shed some light:

    offset
    How many things you have to skip over when moving from the beginning of a string or array to a specific position within it. Thus, the minimum offset is zero, not one, because you don’t skip anything to get to the first item.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: index offset mean?
by muba (Priest) on Jan 18, 2013 at 16:44 UTC

    Perhaps this little sample script will demonstrate the definition.

    $ perl -e ' my $string = "Lorem ipsum"; my @array = qw(The quick brown fox jumps over the lazy dog); for my $offset (0..length($string)) { printf "Offset $offset: %s\n", substr($string, $offset); } for my $offset (0..$#array) { printf "Offset $offset: %s\n", $array[$offset]; } ' Offset 0: Lorem ipsum Offset 1: orem ipsum Offset 2: rem ipsum Offset 3: em ipsum Offset 4: m ipsum Offset 5: ipsum Offset 6: ipsum Offset 7: psum Offset 8: sum Offset 9: um Offset 10: m Offset 11: Offset 0: The Offset 1: quick Offset 2: brown Offset 3: fox Offset 4: jumps Offset 5: over Offset 6: the Offset 7: lazy Offset 8: dog $
Re: index offset mean?
by Anonymous Monk on Jan 19, 2013 at 07:26 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1014081]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-04-19 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (480 votes), past polls