$ perl -MO=Deparse -wce 'sprintf "%x%x%x", ord ("a"), ord ("b"), ord ("c")' Useless use of a constant in void context at -e line 1. BEGIN { $^W = 1; } '???'; -e syntax OK $ #### #!/usr/bin/perl use strict; use warnings 'all'; use Benchmark; timethese -10 => { unpack => '$_ = unpack "H*" => "abc"', sprintf => '$_ = sprintf "%x%x%x", ord ("a"), ord ("b"), ord ("c")', } __END__ Benchmark: running sprintf, unpack for at least 10 CPU seconds... sprintf: 11 wallclock secs (10.25 usr + 0.00 sys = 10.25 CPU) @ 775053.56/s (n=7944299) unpack: 11 wallclock secs (10.48 usr + 0.01 sys = 10.49 CPU) @ 331145.09/s (n=3473712) #### $ perl -MO=Deparse -wce '$_ = sprintf "%x%x%x", ord "a", ord "b", ord "c"' BEGIN { $^W = 1; } $_ = '616263'; -e syntax OK $ #### $ perl -MO=Deparse -wce '($a, $b, $c) = split // => "abc"; $_ = sprintf "%x%x%x", ord $a, ord $b, ord $c' BEGIN { $^W = 1; } ($a, $b, $c) = split(//, 'abc', 4); $_ = sprintf('%x%x%x', ord $a, ord $b, ord $c); -e syntax OK $ #### #!/usr/bin/perl use strict; use warnings 'all'; use Benchmark; use vars qw /$a $b $c $abc/; $abc = "abc"; ($a, $b, $c) = split // => $abc; timethese -10 => { unpack => '$_ = unpack "H*" => $::abc', sprintf => '$_ = sprintf "%x%x%x", ord $::a, ord $::b, ord $::c', } __END__ Benchmark: running sprintf, unpack for at least 10 CPU seconds... sprintf: 11 wallclock secs (10.51 usr + 0.01 sys = 10.52 CPU) @ 208379.75/s (n=2192155) unpack: 10 wallclock secs (10.10 usr + 0.00 sys = 10.10 CPU) @ 323836.04/s (n=3270744)