Jan Harders wrote, on Wednesday, May 17, 2000 09:37
: use MIME::Base64;
: open(FILE, "hans.swf") || die "Konnte die Datei nicht öffnen: ";
: open(FILE2, ">hans.b64") || die "Konnte die Datei nicht öffnen: ";

binmode FILE;

This is a good start, and will probably do all you
need, as pointed out by a couple of others already;
but with binary files, I prefer to use "read" than the
angle-brackets. With binary files, there may be vast
differences in "line sizes", which, with a large file
can cause memory trouble.

Either decide that the files are small, and deliberately
slurp everything in at once:

        { local $/ = ''; $_ = <FILE>; }
        print FILE2 encode_base64($_);

or if the files could be large, use read with a fixed size
buffer (4K in this example):

        my $buffer;
        while ($_ = read(FILE, $buffer, 4096)) {
                print FILE2 encode_base64($_);
        }

: while(<FILE>)
: {
: $string = encode_base64($_);
: print FILE2 "$string";

Oh, and don't enclose a single variable in double quotes; it's
inefficient and looks funny.

: }
: close(FILE);
: close(FILE2);
: -------cut here-------
:
: The Problem is that it doesn't encode the file completely, Just a little
: part of it. Does anybody know what the problem is?

Joe

==============================================================
          Joseph P. Discenza, Sr. Programmer/Analyst
               mailto:[EMAIL PROTECTED]

          Carleton Inc.   http://www.carletoninc.com
          219.243.6040 ext. 300    fax: 219.243.6060

Providing Financial Solutions and Compliance for over 30 Years


---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to
         [EMAIL PROTECTED]

Reply via email to