Convert::BulkDecoder - Extract (binary) data from mail and news messages
use Convert::BulkDecoder; my $cvt = new Convert::BulkDecoder::; # Collect the articles into an array ref. my $art = [<>]; # Decode. my $res = $cvt->decode($art); die("Failed!") unless $res eq "OK"; print "Extracted ", $cvt->{size}, " bytes to file ", $cvt->{file}, "\n";
Convert::BulkDecoder can be used to decode binary contents as included in email and news articles. It supports UUdecoding, ydecoding and MIME attachments. The contents may be split over multiple articles (files), but must be supplied to the decode() function in one bulk.
For yencoded contents, it is possible to verify file consistency using length and checksum tests.
When non-zero (default), the CRC of the data is verified, if possible.
Return a base64 encoded MD5 checksum of the data.
When non-zero, disables duplicate detection.
Produce some information during the operation.
Produce some debugging information during the operation.
The name of the directory where resultant files must be placed. Default is the current directory.
A place where temporary files can be stored, if needed.
A function that gets called with the name of the file as deduced from the data. It must return the desired name of the file to be created.
Default is a function that strips out illegal (and problematic) characters, and turns all blanks into underscores.
Return values are constant strings.
Severe errors are signalled using die(), so you should use try { } to catch them.
try { }
The decode operation completed successfully.
No contents was found.
The operation failed.
The requested file already exists with a non-zero size.
Additionally, this information will be returned in the decoder object:
The return value.
The type of decoding: "M" (MIME), "U" (uudecode) or "Y" (ydecode).
The name of the file created, relative to the destination directory.
The full name (destination directory + name) of the file created.
The length of the data.
A base64 encoded MD5 checksum of the data.
An array reference. Each element is a hash reference that contains the fields result, name, file, size, and md5 for each file that was extracted.
result
name
file
size
md5
If decoding originated in more than one file, the fields result, name, file, size, and md5 will apply to the first file that was extracted.
Only yencoded data can be CRC checked. CRC checking is slow, so only the partial checksums are verified.
Multi-message MIME attachments are not handled yet.
Johan Vromans, Squirrel Consultancy <jvromans@squirrel.nl>
Parts of the ydecoding have been stolen from other tools, in particular newsgrab by Jesper L. Nielsen <lyager@phunkbros.dk>.
Convert::yEnc, Mail::Box.
Copyright 2003 Squirrel Consultancy.
License: Artistic.
To install Convert::BulkDecoder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Convert::BulkDecoder
CPAN shell
perl -MCPAN -e shell install Convert::BulkDecoder
For more information on module installation, please visit the detailed CPAN module installation guide.