in reply to How do unpack templates work

The C template does not help you here. You're probably making a wrong assumption about it. Just stay with H if you want to make hex digits out of octets.

my $uuid = "vz\336\315\216\322\341\21\221\364\261\220z\240\267\344"; # hex 767adecd8ed2e11191f4b1907aa0b7e4 my ($uu1, $uu2) = unpack('H8 H*', $uuid); say $uu1; # 767adecd say $uu2; # 8ed2e11191f4b1907aa0b7e4

Replies are listed 'Best First'.
Re^2: How do unpack templates work
by unlinker (Monk) on Jul 20, 2012 at 17:48 UTC
    Thanks. I do not want hex digits - I just want to split the binary string into two parts. I was using
    substr
    until I read that unpack is faster and more efficient.

      Or you could use a regular expression:

      my ( $uu1, $uu2 ) = $uuid =~ /(\C{4})(\C+)/;