Upgrade to Perl 5.8.8
[msysgit/kusma.git] / lib / perl5 / 5.8.8 / PerlIO / via / QuotedPrint.pm
blob2434191f091624b466a072fb9ecc69fb808d59ea
1 package PerlIO::via::QuotedPrint;
3 # Set the version info
4 # Make sure we do things by the book from now on
6 $VERSION = '0.06';
7 use strict;
9 # Make sure the encoding/decoding stuff is available
11 use MIME::QuotedPrint (); # no need to pollute this namespace
13 # Satisfy -require-
17 #-----------------------------------------------------------------------
18 # IN: 1 class to bless with
19 # 2 mode string (ignored)
20 # 3 file handle of PerlIO layer below (ignored)
21 # OUT: 1 blessed object
23 sub PUSHED { bless \*PUSHED,$_[0] } #PUSHED
25 #-----------------------------------------------------------------------
26 # IN: 1 instantiated object (ignored)
27 # 2 handle to read from
28 # OUT: 1 decoded string
30 sub FILL {
32 # Read the line from the handle
33 # Decode if there is something decode and return result or signal eof
35 my $line = readline( $_[1] );
36 (defined $line) ? MIME::QuotedPrint::decode_qp( $line ) : undef;
37 } #FILL
39 #-----------------------------------------------------------------------
40 # IN: 1 instantiated object (ignored)
41 # 2 buffer to be written
42 # 3 handle to write to
43 # OUT: 1 number of bytes written
45 sub WRITE {
47 # Encode whatever needs to be encoded and write to handle: indicate result
49 (print {$_[2]} MIME::QuotedPrint::encode_qp($_[1])) ? length($_[1]) : -1;
50 } #WRITE
52 __END__
54 =head1 NAME
56 PerlIO::via::QuotedPrint - PerlIO layer for quoted-printable strings
58 =head1 SYNOPSIS
60 use PerlIO::via::QuotedPrint;
62 open( my $in,'<:via(QuotedPrint)','file.qp' )
63 or die "Can't open file.qp for reading: $!\n";
65 open( my $out,'>:via(QuotedPrint)','file.qp' )
66 or die "Can't open file.qp for writing: $!\n";
68 =head1 DESCRIPTION
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.
74 =head1 REQUIRED MODULES
76 MIME::QuotedPrint (any)
78 =head1 SEE ALSO
80 L<PerlIO::via>, L<MIME::QuotedPrint>, L<PerlIO::via::Base64>,
81 L<PerlIO::via::MD5>, L<PerlIO::via::StripHTML>, L<PerlIO::via::Rotate>.
83 =head1 ACKNOWLEDGEMENTS
85 Based on example that was initially added to MIME::QuotedPrint.pm for the
86 5.8.0 distribution of Perl.
88 =head1 COPYRIGHT
90 Copyright (c) 2002-2003 Elizabeth Mattijsen. All rights reserved. This
91 library is free software; you can redistribute it and/or modify it under
92 the same terms as Perl itself.
94 =cut