[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Base64 encoding in Perl
- Subject: [ale] Base64 encoding in Perl
- From: fletch at phydeaux.org (Fletch)
- Date: Mon Feb 14 12:09:04 2005
- In-reply-to: <[email protected]> (Christopher Fowler's message of "Mon, 14 Feb 2005 11:07:28 -0500")
- References: <[email protected]>
>>>>> "Christopher" == Christopher Fowler <cfowler at outpostsentinel.com> writes:
Christopher> I'm trying to use MIME::Base64::encode to encode a 9m
Christopher> binary file into Base64. I'm using sysopen and
Christopher> sysread on the file but I'm not sure how to append
Christopher> the result of the read into a data buffer.
If you check down in the "EXAMPLES" section of "perldoc MIME::Base64"
it says you should just read and encode using a multiple of 57 bytes
to completely fill up a single base64 line:
use MIME::Base64 qw(encode_base64);
open(FILE, "/var/log/wtmp") or die "$!";
while (read(FILE, $buf, 60*57)) {
print encode_base64($buf);
}
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org| Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U