Is
There is no way you get a number of "unpack" consumed "by the call? I just want to parse the various structures of a string (such as the following steps):
my $ record1 = unpack "template", Upastrakt ($ long_str, $ pos); # Advance status indicator $ pos + = NUMBER_OF_BYTES_CONSUMED_BY_LAST_UNPACK (); # Other code can determine which can be read in the following steps # # # my $ record2 = unpack "TEMPLATE2", substr ($ long_str, $ pos) in the new position;
It seems like a glaring omission in the Unpack , Isn't it? As a consolation prize, you can use the end of the unpack template to return the unused portion of the input string a * . # variable-length "W" format is a bit more interesting to make $ X = pack "w *", 126..129; While (length $ x) {# Unpack a number, rest in $ x ($ n, $ x) = "Walk *", $ x; Print $ n; } If your packing string is really long, so it is not a good idea because he has to make a copy of the "balance" of each strap. / P>
No comments:
Post a Comment