Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

update: :) good night

1. I understand what C/xa is doing, but what does @ do in this case? but what does @ do in this case?

Looks like a typo to me :)

http://perldoc.perl.org/perlpacktut.html#The-Alignment-Pit gives the use-case for this one, like a lot of these, its weird :)

Here is what I think I kinda know, remove the @ and you get

'x' outside of string in unpack

So I think @ means start from 0 , where 0 is the beginning for the innermost group (), instead of outside the end of the string :)

So C/x says read one byte/octet, then SKIP(x) that amount of bytes, so it eats the first \003, skips next 3 bytes , which are \003\003a

And its a group, so repeats that three times, each time the C/ eating up one byte, so it inches forward

Yeah, I don't think you can do this in one step, I think it's a 2 step operation like shown in the alignment pit

2. How would I make the template skip from the absolute start of the string, rather than from a relative position? e.g.:

Wait a minute, doesn't this mean you understand 1.?

I think you can't do that, now the original makes even less sense to me

Ok, here's the 2step

use 5.12.0; my $raw = "\003\003\003abcdef"; my @offsets = unpack '(C)3', $raw; my $chucks = join ' ', map { '@' . $_ . 'a' } @offsets; say $chucks; say for unpack $chucks, $raw; use 5.12.0; my $raw = "\003\003\003abcdef"; my @offsets = unpack '(C)3', $raw; my $chucks = join ' ', map { '@' . $_ . 'a' } @offsets; say $chucks; say for unpack $chucks, $raw; __END__ @3a @3a @3a a a a

update: HAHAHAHAHAHAAH I DID IT  (C/x! a@)3 gets you aaa, not sure how that works, makes no sense to me, but its straight from gappy alignment pit portion

This is what I don't like about pack/unpack,


In reply to Re: Pack/unpack - understanding the '@' and '.' templates by Anonymous Monk
in thread [SOLVED] Pack/unpack - understanding the '@' and '.' templactes by ateague

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2024-04-25 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found