ggrise has asked for the wisdom of the Perl Monks concerning the following question:
#!/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, "<test.dat"); open(MYOUTPUTFILE, ">hex.dat"); while(<MYINPUTFILE>) { my($line) = $_; my $line2 ; chomp($line); $line2 = capture_stdout($line) ; print MYOUTPUTFILE "$line2\n"; } close(MYINPUTFILE); close(MYOUTPUTFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting wrong value
by AnomalousMonk (Archbishop) on Jan 15, 2013 at 22:54 UTC | |
by ggrise (Initiate) on Jan 15, 2013 at 23:01 UTC | |
by AnomalousMonk (Archbishop) on Jan 15, 2013 at 23:09 UTC | |
|
Re: getting wrong value
by johngg (Canon) on Jan 15, 2013 at 22:59 UTC | |
|
Re: getting wrong value
by AnomalousMonk (Archbishop) on Jan 16, 2013 at 01:34 UTC | |
|
Re: getting wrong value
by pvaldes (Chaplain) on Jan 16, 2013 at 00:21 UTC |