#!/usr/bin/perl # convert4.pl use warnings; use strict; use Carp (); local $SIG{__WARN__} = \&Carp::cluck; sub capture_stdout($) { my($v); my $line = shift; local *STDOUT; open(STDOUT, '>', \$v); printf ("%#x", $line); return $v; } open(MYINPUTFILE, "hex.dat"); while() { my($line) = $_; my $line2 ; chomp($line); $line2 = capture_stdout($line) ; print MYOUTPUTFILE "$line2\n"; } close(MYINPUTFILE); close(MYOUTPUTFILE);