DIME::Tools(3pm)
β¨ DIME::Tools β the manual page, but make it cute β¨
okay so bestie, welcome to DIME::Tools, a Perl module (that's a 3pm manual page, user-contributed docs, iykyk) π it's the whole vibe of parsing and generating DIME messages. strap in π
πΈ NAME πΈ
DIME::Tools β modules for parsing and generate DIME messages β¨
π¦ SYNOPSIS π¦
π Generating DIME messages
my $payload = DIME::Payload->new();
$payload->attach(Path => "/mydata/index.html",
MIMEType => 'text/html',
Dynamic => 1);
my $payload2 = DIME::Payload->new();
$payload2->attach( Data => "HELLO WORLD!!!",
MIMEType => 'text/plain' );
my $message = DIME::Message->new();
my $payload = DIME::Payload->new();
$payload->attach(Path => "/mydata/index.html",
MIMEType => 'text/html',
Dynamic => 1);
$message->add_payload($payload);
$message->add_payload($payload2);
# Print the encoded message to STDOUT
$message->print(\*STDOUT);
π Parsing DIME messages
my $parser = DIME::Parser->new();
# Open a file with a dime encoded message
$f = IO::File->new("dime.message","r");
my $message = $parser->parse($f);
$f->close();
# Print the content of each payload to STDOUT
for my $i ($message->payloads())
{
print $i->print_content(\*STDOUT);
}
π DESCRIPTION π
DIME-tools is a lil collection of DIME:: modules for parsing and generating DIME encoded messages β that's Direct Internet Message Encapsulation, for the uninitiated π
DIME-tools supports single-record and chunked payloads, so you can send big attachments without it being a whole thing. slay.
fr fr, this distribution hasn't been actively developed since 2004 π the releases after that have just been to get it following CPAN conventions, because there's exactly one distribution depending on it. so like... it's iconic, but it's resting. π«Ά
π GENERATING MESSAGES π
For any content you wanna send in a message, you gotta create a Payload object first:
my $payload = DIME::Payload->new();
$payload->attach(Path => "/mydata/index.html",
MIMEType => 'text/html',
Dynamic => 1);
With the attach method you can specify these keys π
Pathβ the name of the file you wanna attach to the payload object. if the data you wanna attach isn't in a file, you can use theDatakey instead πDataβ it's the reference to a scalar where you store the data you wanna attach.Dynamicβ ifPathis declared, the data is not loaded fully into memory. the only thing you attach to the payload object is the name of the file from thePathkey, not the content itself. lowkey efficient, highkey iconic β¨Chunkedβ if it's declared, it represents the size of the chunk records in bytes. if you don't declare it, the message will not be chunked. periodt.MIMETypeβ the type of the payload. it has to be a string with a MIME standard type. the other option is to useURIType.URITypeβ specifies a URI that defines that type of the content.
π«Ά ATTACH A PAYLOAD TO A MESSAGE π«Ά
my $message = DIME::Message->new();
$message->add_payload($payload);
π PRINT A ENCODED MESSAGE π
# Print prints to any IO::Handle
$message->print(\*STDOUT);
or
# print_data returns a reference to a scalar
print ${$message->print_data()};
π₯ PARSING MESSAGES π₯
All you gotta do is create a DIME::Parser object and call the parse method with an IO::Handle pointing at a DIME message. then you can iterate over the $message->payloads() array to get the contents of the message:
my $parser = DIME::Parser->new();
$f = IO::File->new("dime.message","r");
my $message = $parser->parse($f);
$f->close();
for my $i ($message->payloads())
{
print $i->print_content(\*STDOUTs);
}
You can also call parse_data if you have a DIME message sitting in a scalar variable:
my $dime_message;
my $message = $parser->parse_data(\$dime_message);
And call print_content_data if what you want is to get a reference to the content-data. π
π SEE ALSO π
- Direct Internet Message Encapsulation draft: http://www.gotdotnet.com/team/xml_wsspecs/dime/dime.htm
DIME::Message,DIME::Payload,DIME::Record.
π AUTHOR π
Domingo Alcazar Larrea, <dalcazar@cpan.org> πΈ
π COPYRIGHT AND LICENSE π
Copyright (C) 2004 Domingo AlcΓ‘zar Larrea
This program is free software; you can redistribute it and/or modify it under the terms of the version 2 of the GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307
okay that's the whole thing bestie, no notes πβ¨ this was perl v5.32.1, dated 2021-03-22 β so go forth and parse, and remember: single-record and chunked payloads both ate, and they left no crumbs ππ¦ bye ily π
π¦ where this page comes from
- debian bookworm: libdime-tools-perl 0.05-1 Β· GPL-2.0-only
- debian trixie: libdime-tools-perl 0.05-1 Β· GPL-2.0-only
- ubuntu jammy: libdime-tools-perl 0.05-1 Β· GPL-2.0-only
- ubuntu noble: libdime-tools-perl 0.05-1 Β· GPL-2.0-only
- ubuntu resolute: libdime-tools-perl 0.05-1 Β· GPL-2.0-only
- ubuntu stonking: libdime-tools-perl 0.05-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms