The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PerlIO::Via::Base64 - PerlIO layer for base64 (MIME) encoded strings

SYNOPSIS

 use PerlIO::Via::Base64;

 PerlIO::Via::Base64->eol( "\n" );  # default, write lines 76 bytes long
 PerlIO::Via::Base64->eol( '' );    # no line endings, write one long string

 open( my $in,'<Via(PerlIO::Via::Base64)','file.mime' )
  or die "Can't open file.mime for reading: $!\n";
 
 open( my $out,'>Via(PerlIO::Via::Base64)','file.mime' )
  or die "Can't open file.mime for writing: $!\n";

DESCRIPTION

This module implements a PerlIO layer that works on files encoded in the Base64 format (as described in RFC 2045). It will decode from base64 format while reading from a handle, and it will encode to base64 while writing to a handle.

CLASS METHODS

There is one class method.

eol

 $eol = PerlIO::Via::Base64->eol;  # obtain current setting

 PerlIO::Via::Base64->eol( '' );   # no line endings, one long string
 open( my $out,'>Via(PerlIO::Via::Base64)','file.mime' ); # no line endings

MIME (Base64) encoded files can be written with line endings, causing all lines (except the last) to be exactly 76 bytes long. By default a linefeed ("\n") will be assumed.

Calling this class method with a new value will cause all subsequently opened files to assume that new setting. The eol value however is remembered within the layer, so that it becomes part of the information that is associated with that file.

If it were possible to pass parameters such as this to the layer while opening the file, that would have been the approach taken. Since that is not possible yet, this way of doing it seems to be the next best thing.

CAVEAT

The current implementation slurps the whole contents of a handle into memory before doing any encoding or decoding. This may change in the future when I finally figured out how READ and WRITE are supposed to work on incompletely processed buffers.

SEE ALSO

PerlIO::Via, MIME::Base64, PerlIO::Via::QuotedPrint, PerlIO::Via::MD5, PerlIO::Via::StripHTML.

COPYRIGHT

Copyright (c) 2002 Elizabeth Mattijsen.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.