Re: How to get offset position from unpack()?
- From: Ben Morrow <ben@xxxxxxxxxxxx>
- Date: Wed, 17 Feb 2010 22:30:19 +0000
Quoth "jl_post@xxxxxxxxxxx" <jl_post@xxxxxxxxxxx>:
Quoth "jl_p...@xxxxxxxxxxx" <jl_p...@xxxxxxxxxxx>:
However, there's something I want to do with unpack() that I
haven't figured out how to do: I'd like to unpack part of a
string, but keep track of where the unpacking ended, so I can
resume unpacking the string (at a later time) where I left off.
On Feb 15, 1:48 pm, Ben Morrow <b...@xxxxxxxxxxxx> replied:
~% perl -E'my $x = "aaa"; say for unpack "a2.", $x'
Wow, thanks! The '.' character was exactly what I was looking for!
(I notice it's new in Perl 5.10, so if I'm working for platforms
that have an older version of Perl I'll just have to just the old "a*"
I tried searching for "."'s behavior in "perldoc -f unpack",
"perldoc -f pack", and even "perldoc perlpacktut", but I couldn't find
where it mentions that it returns the offset when used with unpack().
Is there a place that explains this with a little more depth?
If there is, I didn't find it either. I just tried 'unpack "."' and
'unpack "@"' since they looked like likely possibilities, and "."