Mail::D...extWrap(3)
π
Mail::DKIM::TextWrap(3) β the text-wrap bestie page β¨
Okay so this is the Mail::DKIM::TextWrap(3) manual, but make it make sense, bestie. Itβs giving βniche Perl module with main character energy,β and honestly? Iconic.
πΈ NAME
Mail::DKIM::TextWrap β a text-wrapping module written for use with DKIM. Periodt. π
π VERSION
version 1.20240923 β yes, that exact string, no cap.
π¦ DESCRIPTION
Okay so this is a general-purpose text-wrapping module. The author wrote it because they had some specific needs with Mail::DKIM that none of the contemporary text-wrapping modules offered. Lowkey a glow-up moment for line wrapping. β¨
Specifically, it offers the ability to change wrapping options in the middle of a paragraph. For instance, with a DKIM signature:
DKIM-Signature: a=rsa; c=simple; h=first:second:third:fourth;
b=Xr2mo2wmb1LZBwmEJElIPezal7wQQkRQ8WZtxpofkNmXTjXf8y2f0
the line-breaks can be inserted next to any of the colons of the h= tag, or any character of the b= tag. The way this was implemented was to serialize the signature one element at a time, changing the text-wrapping options at the start and end of each tag. The way that works is so specific and so slay. π
β¨ SYNOPSIS (FOR MAIL::DKIM USERS) β¨
use Mail::DKIM::TextWrap;
Just add the above line to any program that uses Mail::DKIM::Signer and your signatures will automatically be wrapped to 72 characters. Literally automatic. π«Ά
π SYNOPSIS (FOR OTHER USERS) π
my $output = "";
my $tw = Mail::DKIM::TextWrap->new(
Margin => 10,
Output => \$output,
);
$tw->add("Mary had a little lamb, whose fleece was white as snow.\n");
$tw->finish;
print $output;
π TEXT WRAPPING OPTIONS
Text wrapping options can be specified when calling new(), or by simply changing the property as needed. For example, to change the number of characters allowed per line:
$tw->{Margin} = 20;
Breakβ a regular expression matching characters where a line break can be inserted. Line breaks are inserted AFTER a matching substring. The default is"/\s/". π¦BreakBeforeβ a regular expression matching characters where a line break can be inserted. Line breaks are inserted BEFORE a matching substring. Usually, you want to useBreak, rather thanBreakBefore. The default is"undef". πΈMarginβ specifies how many characters to allow per line. The default is72. If no place to line-break is found on a line, the line will extend beyond this margin. πSeparatorβ the text to insert when a linebreak is needed. The default is"\n". If you want to set a following-line indent (e.g. all lines but the first begin with four spaces), use something like"\n ". β¨Swallowβ a regular expression matching characters that can be omitted when a line break occurs. For example, if you insert a line break between two words, then you are replacing a "space" with the line break, so you are omitting the space. On the other hand, if you insert a line break between two parts of a hyphenated word, then you are breaking at the hyphen, but you still want to display the hyphen. The default is"/\s/". π no cap, this one is lowkey important.
π CONSTRUCTOR
π new() - create a new text-wrapping object
my $tw = Mail::DKIM::TextWrap->new(
Output => \$output,
%wrapping_options,
);
The text-wrapping object encapsulates the current options and the current state of the text stream. In addition to specifying text wrapping options as described in the section above, the following options are recognized:
Outputβ a scalar reference, or a glob reference, to specify where the "wrapped" text gets output to. If not specified, the default ofSTDOUTis used. π
π METHODS
π add() - process some text that can be wrapped
$tw->add("Mary had a little lamb.\n");
You can add() all the text at once, or add() the text in parts by calling add() multiple times. Fr fr, both are valid. π
π§ finish() - call when no more text is to be added
$tw->finish;
Call this when finished adding text, so that any remaining text in TextWrap's buffers will be output. Itβs the βokay weβre done, flush the vibesβ method. β¨
π₯ flush() - output the current partial word, if any
$tw->flush;
Call this whenever changing TextWrap's parameters in the middle of a string of words. It explicitly allows a line-break at the current position in the string, regardless of whether it matches the current break pattern. The way thatβs so βtrust me bestie, break hereβ of it. π
π«Ά AUTHORS
Jason Long <jason@long.name>πMarc Bradshaw <marc@marcbradshaw.net>πBron Gondwana <brong@fastmailteam.com> (ARC)β
π THANKS
Work on ensuring that this module passes the ARC test suite was generously sponsored by Valimail (https://www.valimail.com/). Obsessed with the sponsorship moment. π«Ά
π COPYRIGHT AND LICENSE
- Copyright (C) 2013 by Messiah College
- Copyright (C) 2010 by Jason Long
- Copyright (C) 2017 by Standcore LLC
- Copyright (C) 2020 by FastMail Pty Ltd
Legal bit, bestie: this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available. π
Source/version vibes: perl v5.42.0, page dated 2024-09-23, and itβs the Mail::DKIM::TextWrap(3) page being iconic till the end. Bye bestie β mwah πβ¨
π¦ where this page comes from
- alpine 3.23: perl-mail-dkim-doc 1.20240923-r0 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- opensuse-leap 16.0: perl-Mail-DKIM 1.20240923-bp160.1.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms