#!/usr/bin/perl

#-------------------------------------------------------------------------------
---
#
# Usage:  bin2hex file
#
#-------------------------------------------------------------------------------
---

&Usage if $#ARGV < $[;

open (STDIN, $ARGV[0]) || die "Can't open $ARGV[0]: $!\n" if $ARGV[0];

$offset = 0;
seek(STDIN, $offset, SEEK_SET);

while (($len = read(STDIN, $data, 16)) != 0 )
{
    while((length $data) %4 != 0)
    {
        $data = sprintf("%s\0", $data);
    }
    @array = unpack('V16', $data);
    $data =~tr/\0-\37\177-\377/./;
    printf "%8.8lx %8.8lx %8.8lx %8.8lx\n", $array[0], $array[1], $array[2],
$array[3] ;
    $offset += 16;
}

#-------------------------------------------------------------------------------
---
#
# This Usage routine reads and prints everthing in this file between the first
#  pair of  "#-"  lines.
#
#-------------------------------------------------------------------------------
---
sub Usage
{
    print "file is < $0 > \n";
    open( FILE, $0) || die "Can't open $0\n";
    while ( ($_=<FILE>) && !($_=~ /^#-.*/) ) { ; }
    print "$_";
    while ( ($_= <FILE>) && !($_=~ /^#-.*/) ) { print "$_"; }
    print "$_";
    close(FILE);
    exit 0;
}

