in reply to Help: Mime decoding of a large file
It should work just fine to decode the file line by line. "Proof":
#!/usr/bin/perl use MIME::Base64 (); my $file_name = shift @ARGV; my $buf; open my $fh_in, "<", $file_name or die $!; open my $fh_out, ">", $file_name.".base64" or die $!; while (read($fh_in, $buf, 100*57)) { print $fh_out MIME::Base64::encode($buf); } close $fh_out; open my $fh_base64, "<", $file_name.".base64" or die $!; open my $fh_decoded, ">", $file_name.".decoded" or die $!; while ($buf = <$fh_base64>) { print $fh_decoded MIME::Base64::decode($buf); } __END__ $ ./757820.pl hugefile $ ls -l hugefile* -rw-r--r-- 1 almut almut 618119168 2009-02-07 02:01 hugefile -rw-r--r-- 1 almut almut 835003088 2009-04-16 04:51 hugefile.base64 -rw-r--r-- 1 almut almut 618119168 2009-04-16 04:51 hugefile.decoded $ cmp hugefile hugefile.decoded $
Do you maybe have some junk around the actual base64 data section in your encoded file, or is it maybe additionally transfer-encoded one way or another (e.g. quoted-printable)?
|
|---|