Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow List as template in pack, like in unpack
  • Loading branch information
lizmat committed Dec 4, 2015
1 parent 612f547 commit 734549a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/Buf.pm
Expand Up @@ -317,9 +317,14 @@ constant buf16 = Buf[uint16];
constant buf32 = Buf[uint32];
constant buf64 = Buf[uint64];

proto sub pack(|) { * }
multi sub pack(Str $template, *@items) {
pack($template.comb(/<[a..zA..Z]>[\d+|'*']?/), @items)
}

multi sub pack(@template, *@items) {
my @bytes;
for $template.comb(/<[a..zA..Z]>[\d+|'*']?/) -> $unit {
for @template -> $unit {
my $directive = substr($unit,0,1);
my $amount = substr($unit,1);

Expand Down

0 comments on commit 734549a

Please sign in to comment.