1 package PerlIO::via::QuotedPrint;
3 # Make sure we do things by the book
7 $PerlIO::via::QuotedPrint::VERSION = 0.01;
9 # Make sure the encoding/decoding stuff is available
11 use MIME::QuotedPrint (); # no need to pollute this namespace
13 #-----------------------------------------------------------------------
14 # IN: 1 class to bless with
15 # 2 mode string (ignored)
16 # 3 file handle of PerlIO layer below (ignored)
17 # OUT: 1 blessed object
19 sub PUSHED { bless [],$_[0] } #PUSHED
21 #-----------------------------------------------------------------------
22 # IN: 1 instantiated object (ignored)
23 # 2 handle to read from
24 # OUT: 1 decoded string
28 # Read the line from the handle
29 # Decode if there is something decode and return result or signal eof
31 my $line = readline( $_[1] );
32 (defined $line) ? MIME::QuotedPrint::decode_qp( $line ) : undef;
35 #-----------------------------------------------------------------------
36 # IN: 1 instantiated object (ignored)
37 # 2 buffer to be written
38 # 3 handle to write to
39 # OUT: 1 number of bytes written
43 # Encode whatever needs to be encoded and write to handle: indicate result
45 (print {$_[2]} MIME::QuotedPrint::encode_qp($_[1])) ? length($_[1]) : -1;
56 PerlIO::via::QuotedPrint - PerlIO layer for quoted-printable strings
60 use PerlIO::via::QuotedPrint;
62 open( my $in,'<Via(PerlIO::via::QuotedPrint)','file.qp' )
63 or die "Can't open file.qp for reading: $!\n";
65 open( my $out,'>Via(PerlIO::via::QuotedPrint)','file.qp' )
66 or die "Can't open file.qp for writing: $!\n";
70 This module implements a PerlIO layer that works on files encoded in the
71 quoted-printable format. It will decode from quoted-printable while reading
72 from a handle, and it will encode as quoted-printable while writing to a handle.
76 L<PerlIO::via>, L<MIME::QuotedPrint>, L<PerlIO::via::Base64>, L<PerlIO::via::MD5>,
77 L<PerlIO::via::StripHTML>.
81 Copyright (c) 2002 Elizabeth Mattijsen. Based on example that was initially
82 added to MIME::QuotedPrint.pm for the 5.8.0 distribution of Perl.
84 This library is free software; you can redistribute it and/or
85 modify it under the same terms as Perl itself.