thanks for the help..  i use binmode when encoding etc.. and thats works
fine..  what i was trying to get is decoding the info..  ie in a email etc..
taking the attachment and decoding it back into a file..  like the one I
listed... but the problem is when it decode and gets stored to disc it gets
strewed up..

and i am using MIME::Base64

$buf is the encoded data from the message...

unlink ("/temp/test.gif");
open (W, ">/temp/test.gif");
print W &decode_base64($buf);
close W;

the only other reason i can think this is not working is some how a return
character is in the string..

because the coding into a message works fine etc.. and outlook express
decodes that 100%.. but then i try it using perl..  will thats when the
problem happens.. with the decoding..  encoding works 100% using the binmode
cmds etc...

Johnno

From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: "Johnno" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, November 15, 2000 1:06 PM
Subject: Re: Mime Encoding and decoding.


> Johnno wrote:
> >
> > Hello All,
> >
> > I have manged to get MIME::base64 to encode the file etc...
> >
> > but when i decode it back it get strewed up... here is the test script.
> >
> > #####
> >  use MIME::Base64;
> >
> > $buf =
> >
"R0lGODdhKAAoAOMAAAAAAAAAgB6Q/y9PT25ubnCAkKBSLb6+vufn5/Xes/+lAP/6zQAAAAAA
> > AAAAAAAAACwAAAAAKAAoAAAE/hDJSau9eJLMOyYbcoxkaZ5oCkoH6L5wLMfiWqd4btZhmxbA
> > oFCY47EIqMJgyWw2ATjj7aRkAq5YwDMl9VGtKO0SiuoiTVlscsxt9c4HgXxUIA0EAVOVfDKT
> > 8Hl1B3kDAYYle202XnGGgoMHhYckiWVuR3+OTgCGeZRslotwgJ2lnYigfZdTjQULr7ALBZN0
> > qTurjHgLKAu0B5Wqopm7J72etQN8t8Ijury+wMtvw8/Hv7Ylfs0BxCbGqMmK0yOOQ0GTCgrR
> > 2bhwJGlXJQYG6mMKoeNoWSbzCWIACe5JwxQm3AkDAbUAQCiQhDZEBeBl6afgCsOBrD45edIv
> > QceGWSMevpOYhl6CkydBHhBZQmGKjihVshypjB9ClAHZMTugzOU7mzhBPiSZ5uDNnA7b/aTZ
> > 0mhMnfl0pDBFa6bUElSPWb0qtYuHrxlwcR17YsWMs2jTql3LFkQEADs=";
> >
> > unlink ("/temp/test.gif");
> > open (W, ">/temp/test.gif");
> > print W decode_base64($buf);
> > close W;
> > ####
> >
> > any ideas..  if i send this to my email client as a email message etc..
it
> > works fine...  the problem is it not work with the
> > decode_bas64($buf) the gif image gets strewed..
>
> How did you encode your GIF?  My guess is you didn't use binary mode.
>
> This works fine:
>
> use strict;
> use MIME::Base64;
>
> my $use_hardcoded = 1;
> my $gif;
>
> # acquire GIF into string
> {
> local $/ = undef;
> my $file = 'new.gif';
> open IN, $file or die "Error opening $file: $!";
> binmode IN; # use binary mode
> $gif = <IN>; # slurp entire GIF
> close IN;
> }
>
> my $buf;
>
> if ($use_hardcoded) {
>
> $buf =
>
'R0lGODdhFwAMAPEAAL+/v///AMwAAwAAACwAAAAAFwAMAAACO4QRh2qR3FySj7pos6YoCPkJYkh
9' .
> 'FyI6JFieqAePqrdGZmqqY3rMc+7LdWA/GRG4SWowLg4H0mE8etMCADs=';
>
> } else {
>
> $buf = &encode_base64 ($gif);
> print $buf; # copy this to hard coded $buf above
> }
>
> unlink ("test.gif");
> open OUT, ">test.gif";
> print OUT &decode_base64($buf);
> close OUT;
>
> __END__
>
>
> --
>   ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
>  (_/   /  )    // //       DBE Collectibles   http://www.wgn.net/~dbe/
>   / ) /--<  o // //      Mailto:[EMAIL PROTECTED]   http://dbecoll.webjump.com/
> -/-' /___/_<_</_</_    http://www.freeyellow.com/members/dbecoll/
> _______________________________________________
> Perl-Win32-Web mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to