Re: How to get offset position from unpack()?

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 "."



Relevant Pages

  • Re: Optimization help - reading out of /proc on Solaris
    ... string slicing and unpacking. ... we have a symbol mapping to an unpack format string segment ... #repeat the above with a new array instead of FIELDS and a new method name ... # # Print process table information for only pid 1001 ...
  • Unpack When? Part II
    ... user interface or is it better to do all the work in Pick on the server and ... response to adding a string at the end of a previous string (ie like x += ... So I wonder if this would make a difference as to when to unpack? ... maybe we *should* unpack client-side. ...
  • Re: unpack "B*", 15
    ... You seem to be misunderstanding what unpack and pack do, ... pack takes a list of perl values, and packs them into a 'string', which ... packing of structs from a perl program in a simiar way a C program would ...
  • How to get offset position from unpack()?
    ... The unpack() function is very, very useful for me, as I regularly ... do a lot of unpacking of non-Perl-created data strings to see what ... the string where I left off. ... I could calculate this offset myself by examining what was ...
  • Re: using the unpack function to grab a field name
    ... Now I want to unpack the $header array and create two strings, ... I don't know how to use unpack but I have the $header array as the ... function body simply returns a string, there is no array involved from where I can see. ... When the user clicks one of those links, the query string variables are sent to $file_name. ...