develooper Front page | perl.perl5.porters | Postings from August 2012

Re: RFC: pack()ing long words

Thread Previous
From:
Leon Timmermans
Date:
August 13, 2012 04:49
Subject:
Re: RFC: pack()ing long words
Message ID:
CAHhgV8jYNyaYrtCQq7gmbw8zipmCWdogjELkX9MOLq-tHPygUQ@mail.gmail.com
On Mon, Aug 13, 2012 at 2:41 PM, David Cantrell <david@cantrell.org.uk> wrote:
> pack() and unpack() can handle words of 1, 2, 4, and (if you built your
> perl right) 8 bytes.  And I use the same magic characters (although
> without using pack and unpack) in Data::Hexdumper.
>
> However, I want to extend it to support 16 byte words and, indeed, to
> support any other length words.  3 byte words, for example.

That sounds like an excellent idea.

> I'd like to remain as compatible as possible with the characters used in
> pack()'s templates, but there's nothing there for what I want.
>
> So, can I propose that we pick a character for this purpose and at least
> define some syntax for specifying a word length, endian-ness, and repeat
> count for it, even if it isn't implemented yet?
>
> Something like this perhaps:
>   X5,4>
>
> which means:
>   X  - whatever letter we choose
>   5  - word length
>   ,4 - optional repeat count
>   >  - optional endian-ness

I don't like the syntax much, but I'm not sure I can think of
something better. Maybe «X{5}4»?

Leon

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About