All pastes #424567 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-04 21:27 UTC
rendered paste body
0000000 0100 0000 0000 0000 3800 0000 0100 0000
here is a line of hex info from a file i displayed using od
I need that info to look like the following
0000000 0000 0010 0000 0000 0000 0038 0000 0010

here is the code i am using


#!/usr/bin/perl

my $input  = $ARGV[0] or die "Usage: $0 <input> <output>";
my $output = $ARGV[1] or die "Usage: $0 <input> <output>";

open(my $in_fh,  '<', $input)  or die "Unable to open '$input'  for reading: $!";
open(my $out_fh, '>', $output) or die "Unable to open '$output' for writing: $!";

local $/ = \1;
while (<$in_fh>) {
   my $little = unpack 'v', $_;
   my $big = pack 'n', $little;
   print $out_fh $big;
}
__END__
# untested