***** infoCopter.com/perl *****
ISO2HexUseful as /usr/local/bin/iso2hex
#!/usr/bin/perl -w
# Usage:
# ./iso2hex.pl < input
use strict;
&main();
sub main() {
while (<>) {
chomp;
my $hex = &iso2hex($_); $hex =~ tr/ //d;
print $hex, "\n";
}
}
sub iso2hex($) {
my $hex = '';
for (my $i = 0; $i < length($_[0]); $i++) {
my $ordno = ord substr($_[0], $i, 1);
my $hx = sprintf("%lx ", $ordno);
$hx = "0$hx" if length($hx) < 3;
$hex .= $hx;
}
$hex =~ s/ $//;
$hex;
}
|