IM::Address(3pm)

πŸ“¦
version 153 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– IM::Address πŸ’–

okay bestie, so this is a page from the Internet Message Perl modules set, and it's filed under manual name IM::Address (section 3pm, if you're keeping track). it's a whole module. it parses addresses. let's GO πŸ¦‹


✨ NAME ✨

IM::Address β€” RFC822 style address parser

like, it takes email-ish addresses that are all dressed up in comments and display names, and it finds the actual address hiding underneath. no cap. πŸ’…


🌸 SYNOPSIS 🌸

here's the vibe, bestie β€” copy these exactly:

use IM::Address;

$pure_address_portion = &extract_addr($address_with_comment);

$replaced_address = &replace_addr($original_address_with_comment,
    $pure_notation_of_old_address, $pure_notation_of_new_address);

($first, $rest) = &fetch_addr($address_list, $pure_address_flag);

three little functions, three little jobs. iconic behavior honestly πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so, the tea: the IM::Address module is a parser for RFC822 style address. that's the whole thing. it parses them. beautifully. πŸ’–

and this module is provided by IM (Internet Message). that's the family it belongs to, and we love her for it 🫢


🌈 EXAMPLES 🌈

okay these are the fun part, let's run through them:

  • first one: with
$a = "Motonori Nakamura <motonori\@econ.kyoto-u.ac.jp>";

then &extract_addr($a) returns "motonori@econ.kyoto-u.ac.jp".

see what happened?? it extracted just the pure address out of the whole decorated string. the name and the angle brackets got left behind. so clean ✨

  • second one: with
$a = "Motonori Nakamura <motonori\@econ.kyoto-u.ac.jp>";
$b = "motonori\@econ.kyoto-u.ac.jp";
$c = "motonori\@wide.ad.jp";

then &replace_addr($a, $b, $c) returns "Motonori Nakamura <motonori@wide.ad.jp>".

so it found $b inside $a, swapped in $c, and kept the original pretty formatting around it. the display name stayed. the angle brackets stayed. only the address itself changed. that's the whole point and it ATE πŸ”₯

  • third one: with
$a = "kazu, nom, motonori";

then &fetch_addr($a, 0) returns ("kazu", " nom, motonori").

note the space in front of " nom, motonori" β€” that's not a typo, that's literally what it returns, so don't come for me πŸ’€ it pulled off the first address in the list and handed you back the rest, comma-and-space intact.


IM (Internet Message) is copyrighted by the IM developing team. you can redistribute it and/or modify it under the modified BSD license. see the copyright file for more details. πŸŽ€


and that's the whole page bestie!! πŸ’…

this beauty is version IM153, dated 2016-10-10 β€” so yeah, she's been serving since 2016 and she's still out here parsing. mwah. take care of her, and remember: extract, replace, fetch, slay βœ¨πŸ¦‹πŸ’–

πŸ“¦ where this page comes from