UPDATE: I got my example to work with the following code:
Thank you Loops and 7stud for your help.say unpack '(C.*/X/xa@1)3', "\003\003\003abcdef"; # prints 'aaa' say unpack '(C.*/X/xa@1)3', "\005\004\003abcdef"; # prints 'cba'
I have a pretty good grasp of the "standard" templates, but I simply cannot get my head around the "@" and "." templates.
Does anyone know of (or have) any tutorials/examples that delve more in depth with the "@" and "." templates? perldoc pack and perlpacktut have the briefest mention of "@" and (to my eyes) no mention of ".".
A more concrete example: After playing around with pack and the "/" modifier, I came up with the following:
1. I understand what C/xa is doing, but what does @ do in this case?say unpack '(C/xa@)3', "\003\003\003abcdef"; # prints 'bcd' say unpack '(C/xa@)3', "\005\004\003abcdef"; # prints 'ddd'
2. How would I make the template skip from the absolute start of the string, rather than from a relative position?
e.g.:
say unpack '(C/xa@)3', "\003\003\003abcdef"; # prints 'bcd' - would li +ke 'aaa' say unpack '(C/xa@)3', "\005\004\003abcdef"; # prints 'ddd' - would li +ke 'cba'
Thank you for your time.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |