[ TOFU fixed ]

Joel wrote:
> 
> From: "John W. Krahn" <[EMAIL PROTECTED]>
> 
> > Joel wrote:
> > >
> > > I'm trying to write a program in perl that will take a binary file,
> > > convert it to hex, then save it to a text file.
> >
> > Perhaps this is what you want:
> >
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
> >
> > print 'Enter path: ';
> > chomp( my $filename = <STDIN> );
> >
> > print 'Save as what? ';
> > chomp( my $savefile = <STDIN> );
> >
> > open BINARY, '<', $filename or die "Couldn't open file: $!";
> > binmode BINARY;
> > open SAVE, '>', $savefile or die "Unable to save: $!";
> >
> > while ( <BINARY> ) {
> >     print SAVE unpack( 'H*', $_ ), "\n";
> >     }
> >
> > close BINARY;
> > close SAVE;
> >
> > __END__
> 
> Thanks, that works perfectly. Now I just have to figure out how to turn it
> back into a valid file. I tried using "pack 'b*'" but I had no luck. Any
> suggestions?

while ( <TEXT> ) {
    chomp;
    print BINARY pack 'H*', $_;
    }


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to