Convert-yEnc
view release on metacpan or search on metacpan
lib/Convert/yEnc/Decoder.pm view on Meta::CPAN
$beginSize == $fileSize or
die ref $decoder,
"::_end: BeginSize $beginSize != FileSize $fileSize\n";
}
$temp->{size} = $decodeSize;
}
sub name { shift->{temp}{name} }
sub file { shift->{temp}{file} }
sub size { shift->{temp}{size} }
sub ybegin { shift->{temp}{line}{ybegin} }
sub ypart { shift->{temp}{line}{ypart } }
sub yend { shift->{temp}{line}{yend } }
1
__END__
=head1 NAME
Convert::yEnc::Decoder - decodes yEncoded files
=head1 SYNOPSIS
use Convert::yEnc::Decoder;
$decoder = new Convert::yEnc::Decoder;
$decoder = new Convert::yEnc::Decoder $dir;
$decoder->out_dir($dir);
eval
{
$decoder->decode( $file);
$decoder->decode(\*FILE);
$decoder->decode;
};
print $@ if $@;
$name = $decoder->name;
$file = $decoder->file;
$size = $decoder->size;
$ybegin = $decoder->ybegin;
$ypart = $decoder->ypart;
$yend = $decoder->yend;
=head1 ABSTRACT
yEnc decoder
=head1 DESCRIPTION
C<Convert::yEnc::Decoder> decodes a yEncoded file and writes it to disk.
Methods are provided for returning information about the decoded file.
=head2 Exports
Nothing.
=head2 Methods
=over 4
=item I<$decoder> = C<new> C<Convert::yEnc::Decoder>
=item I<$decoder> = C<new> C<Convert::yEnc::Decoder> I<$dir>
Creates and returns a new C<Convert::yEnc::Decoder> object.
Decoded files will be written to I<$dir>.
If I<$dir> is omitted,
it defaults to the current working directory.
=item I<$decoder>->C<out_dir>(I<$dir>)
Sets the output directory to I<$dir>.
=item I<$decoder>->C<decode>(I<$file>)
=item I<$decoder>->C<decode>(I<\*FILE>)
=item I<$decoder>->C<decode>
Decodes a file.
C<die>s if there are any errors.
The first form reads from the file named I<$file>.
The second form reads from the file handle I<FILE>.
The third form reads from C<STDIN>.
The data stream need not begin at the C<=yBegin> line;
C<decode> will search until it finds it.
C<decode> stops reading when it finds the C<=yend> line,
so C<Decoder> can decode multiple files from the same
data stream.
C<decode> may be called repeatedly on the same C<Decoder> object
to decode multiple files.
=item I<$name> = I<$decoder>->C<name>
After a successful decode,
returns the name of the file that was created.
=item I<$file> = I<$decoder>->C<file>
After a successful decode,
returns the complete path of the file that was created.
=item I<$size> = I<$decoder>->C<size>
After a successful decode,
returns the size of the decoded file.
=item I<$ybegin> = I<$decoder>->C<ybegin>
After a successful decode,
returns the C<=ybegin> line.
=item I<$ypart> = I<$decoder>->C<ypart>
After a successful decode,
returns the C<=ypart> line,
or undef if there wasn't one.
=item I<$yend> = I<$decoder>->C<yend>
After a successful decode,
returns the C<=yend> line.
=back
=head1 NOTES
=head2 1-liner
To decode a single file on the command line, write
perl -MConvert::yEnc::Decoder -e 'Convert::yEnc::Decoder->new->decode' < myFile
=head1 TODO
=over 4
=item *
CRCs
=back
=head1 SEE ALSO
=over 4
=item *
L<Convert::yEnc>
=item *
L<http://www.yenc.org>
=item *
L<http://www.yenc.org/yenc-draft.1.3.txt>
=back
( run in 1.075 second using v1.01-cache-2.11-cpan-140bd7fdf52 )