2
0

oct2bin 235 B

123456789101112
  1. #!/usr/bin/perl
  2. # Turn C-style octal escapes into binary.
  3. # Call as "echo -n 'ab\0\001cd' | oct2bin > out.binmode".
  4. binmode STDOUT;
  5. while (<>) {
  6. s/\\(\d\d\d)/chr(oct($1))/ge;
  7. s/\\0/chr(0)/ge;
  8. s/\\\\/\\/g;
  9. print $_;
  10. }