#!/usr/bin/perl
use strict;
use warnings;
my @values = (0, 1, 5, 25, 100, 200, 255);
print join(", ", map { unpack "H*", chr } @values), $/;
__END__
00, 01, 05, 19, 64, c8, ff
You may also consider printf/sprintf with the X indicator:#!/usr/bin/perl
use strict;
use warnings;
my @values = (0, 1, 5, 25, 100, 200, 255, 500, 1000);
print join(", ", map { sprintf "%X", $_ } @values), $/;
__END__
0, 1, 5, 19, 64, C8, FF, 1F4, 3E8
Note that this second solution works well with numbers beyond 255. You can also pad with zeroes on the left, just look in the docs for sprintf.
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
|