From ba03136d0d40bf219b4923855a3a2b20c03babd7 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 29 May 2009 15:47:20 -0700 Subject: [PATCH] bin2hex: actually account for the number of bytes written Unlike C, in Perl printf() doesn't return the number of bytes written. Signed-off-by: H. Peter Anvin --- utils/bin2hex.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/bin2hex.pl b/utils/bin2hex.pl index 0cb486e..778b699 100644 --- a/utils/bin2hex.pl +++ b/utils/bin2hex.pl @@ -26,12 +26,15 @@ ## ## ----------------------------------------------------------------------- -eval { use bytes; }; eval { binmode STDIN; }; +eval { use bytes; }; +eval { binmode STDIN; }; $len = 0; while ( read(STDIN,$ch,1) ) { $cc = ord($ch); - $len += printf ("%x", $cc); + $s = sprintf("%x", $cc); + print $s; + $len += length($s); if ( $len > 72 ) { print "\n"; $len = 0; -- 2.7.4