Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created January 28, 2018 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/7d0aaef60fcf8e1e9735395477b71ee9 to your computer and use it in GitHub Desktop.
Save zoffixznet/7d0aaef60fcf8e1e9735395477b71ee9 to your computer and use it in GitHub Desktop.
$*OUT.write: do given "/tmp/sample.input".IO.slurp: :bin {
my $out := buf8.new;
my int $decode = 0;
my $buf;
for $_ -> int $_ {
if $_ == 37 { $decode++ }
elsif $decode {
$buf ~= .chr;
if $decode++ == 2 {
$out.push: parse-base $buf, 16;
$decode = 0;
$buf = '';
}
}
else { $out.push: $_ }
}
$out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment