Hi,

In Perl5 one can do a search and replace on binary data. Something like
this works fine:

perl -pe 's/abc/def/' data > data.out

The Perl6 straight equivalent

perl6 -pe 's/abc/def/' data > data.out

throws an exception:

Malformed UTF-8
  in block <unit> at -e line 1

which is completely understandable.
But even writing a program which handles binary data, such as:

my $fh = open 'data', :r, :bin;
while my $line = $fh.read(8192) {
  ...
  $*OUT.write($line)
}

is of no help, because in this case $line is a Buf[uint8], which has no
subst or match(Buf[uint8]: Regex) method available.
Is there any way shorter than pack/unpack to handle binary data?

Thanks!

-- 
Fernando Santagata

Reply via email to