Trag has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use warnings; use strict; my $hexbin = shift; my $filename = shift; my $savefile = shift; open (INPUT,"$filename") || die "Couldn't open file: $!"; open (OUTPUT,">$savefile") || die "Unable to save: $!"; if ($hexbin eq "-h"||"-H") { binhex(); } elsif ($hexbin eq "-b"||"-B") { hexbin(); } close INPUT; close OUTPUT; exit 0; sub binhex { binmode INPUT; while (<INPUT>) { print OUTPUT unpack ('H*', $_), "\n"; } } sub hexbin { while (<INPUT>) { print OUTPUT pack ('H*', $_), "\n"; } }
#!/usr/bin/perl use warnings; use strict; my $filename = shift; my $savefile = shift; open (HEX,"$filename") || die "Couldn't open file: $!"; open (SAVEFILE,">$savefile") || die "Unable to save: $!"; while (<HEX>) { print SAVEFILE pack ('H*', $_), "\n"; } close HEX; close SAVEFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hex editor
by japhy (Canon) on May 13, 2004 at 15:48 UTC | |
|
Re: Hex editor
by Sandy (Curate) on May 13, 2004 at 15:19 UTC | |
by Trag (Monk) on May 13, 2004 at 15:32 UTC | |
by Sandy (Curate) on May 13, 2004 at 15:42 UTC | |
|
Re: Hex editor
by graff (Chancellor) on May 14, 2004 at 02:56 UTC |