Current Perl documentation can be found at perldoc.perl.org.
Here is our local, out-dated (pre-5.6) version:
The MIME-tools package (available from CPAN) handles this and a lot more. Decoding BASE64 becomes as simple as:
use MIME::base64; $decoded = decode_base64($encoded);
A more direct approach is to use the
unpack()
function's ``u'' format after minor transliterations:
tr#A-Za-z0-9+/##cd; # remove non-base64 chars tr#A-Za-z0-9+/# -_#; # convert to uuencoded format $len = pack("c", 32 + 0.75*length); # compute length byte print unpack("u", $len . $_); # uudecode and print