Skip to content

Instantly share code, notes, and snippets.

@jstaursky
Created June 28, 2019 16:00
Show Gist options
  • Save jstaursky/4895b18e33c840a5745aae8b83b003e8 to your computer and use it in GitHub Desktop.
Save jstaursky/4895b18e33c840a5745aae8b83b003e8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use warnings;
while (read STDIN, my $octets, 3) {
# converts the 3 octal numbers to equivalent decimal number and then said
# decimal number into its hex equivalent.
$hex_fmt = sprintf "%02x", oct($octets);
# print out hex in raw hex byte values.
print pack("H*", $hex_fmt);
}
@jstaursky
Copy link
Author

UPDATE
0xa0 is newline in hex. So just use that when appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment