AnyEven...P::Util(3)
π NAME π
okay so this is the AnyEven...P::Util(3) page from the User Contributed Perl Documentation, bestie β and it's the manual for AnyEvent::XMPP::Util, aka Utility functions for AnyEvent::XMPP. It's giving utility-helper era, and honestly? iconic. π
β¨
β¨ SYNOPSIS β¨
like, you load it and pull in the function you want:
use AnyEvent::XMPP::Util qw/split_jid/;
...
That ... is doing its own little thing fr fr.
π οΈ FUNCTIONS π οΈ
These functions can be exported if you want β slay.
resourceprep ($string)
This one applies the stringprep profile for resources to $string and returns the result. cute, focused, resource-coded. β¨
nodeprep ($string)
Same idea but for nodes: it applies the stringprep profile for nodes to $string and returns the result. π
prep_join_jid ($node, $domain, $resource)
This joins the parts $node, $domain and $resource into a full jid and applies stringprep profiles. If the profiles couldn't be applied, undef will be returned. no cap. π«Ά
join_jid ($user, $domain, $resource)
This is a plain concatenation of $user, $domain and $resource β without stringprep. Just vibes and string gluing. π
See also prep_join_jid.
split_uri ($uri)
This splits up $uri into the service and node part and returns them as a list:
my ($service, $node) = split_uri ($uri);
split_jid ($jid)
This splits up $jid into user/node, domain and resource part and returns them as a list:
my ($user, $host, $res) = split_jid ($jid);
breaking a JID into its little main-character parts, basically. π¦
node_jid ($jid)
See "prep_res_jid" below. π
domain_jid ($jid)
See "prep_res_jid" below. π
res_jid ($jid)
See "prep_res_jid" below. π
prep_node_jid ($jid)
See "prep_res_jid" below. π
prep_domain_jid ($jid)
See "prep_res_jid" below. π
prep_res_jid ($jid)
These functions return the corresponding parts of a JID. The "prep_" prefixed JIDs return the stringprep'ed versions. β¨
stringprep_jid ($jid)
This applies stringprep to all parts of the jid according to the RFC 3920. highkey use this if you want to compare two jids like this:
stringprep_jid ($jid_a) eq stringprep_jid ($jid_b)
This function returns undef if the $jid couldn't successfully be parsed and the preparations done. π
cmp_jid ($jid1, $jid2)
This compares two jids $jid1 and $jid2 whether they are equal. periodt. π
cmp_bare_jid ($jid1, $jid2)
This compares two jids $jid1 and $jid2 whether their bare part is equal. π
prep_bare_jid ($jid)
This makes the jid $jid a bare jid β meaning: it will strip off the resource part. With stringprep. β¨
bare_jid ($jid)
This makes the jid $jid a bare jid β meaning: it will strip off the resource part. But without stringprep. π
is_bare_jid ($jid)
This method returns a boolean which indicates whether $jid is a bare JID. yup, that's it. π¦
filter_xml_chars ($string)
This removes all characters from $string which are not allowed in XML and returns the new string. bye forbidden chars π
filter_xml_attr_hash_chars ($hashref)
This runs all values of the $hashref through "filter_xml_chars" (see above) and changes them in-place! π¨ no cap, it mutates them.
simxml ($w, %xmlstruct)
This takes a XML::Writer as first argument ($w) and the rest key value pairs:
simxml ($w,
defns => '<xmlnamespace>',
node => <node>,
prefixes => { prefix => namespace, ... },
);
Where node is:
<node> := {
ns => '<xmlnamespace>',
name => 'tagname',
attrs => [ 'name', 'value', 'name2', 'value2', ... ],
childs => [ <node>, ... ]
}
| {
dns => '<xmlnamespace>', # this will set that namespace to
# the default namespace before using it.
name => 'tagname',
attrs => [ 'name', 'value', 'name2', 'value2', ... ],
childs => [ <node>, ... ]
}
| sub { my ($w) = @_; ... } # with $w being a XML::Writer object
| "textnode"
Please note: "childs" stands for "child sequence" :-)
Also note that if you omit the "ns" key for nodes there is a fall back to the namespace of the parent element or the last default namespace. This makes it easier to write things like this:
{
defns => 'muc_owner',
node => { name => 'query' }
}
(Without having to include "ns" in the node.)
Please note that all attribute values and character data will be filtered by "filter_xml_chars". π§Ό
This is a bigger example:
...
$msg->append_creation( sub {
my($w) = @_;
simxml($w,
defns => 'muc_user', # sets the default namepsace for all following elements
node => {
name => 'x', # element 'x' in namespace 'muc_user'
childs => [
{
'name' => 'invite', # element 'invite' in namespace 'muc_user'
'attrs' => [ 'to', $to_jid ], # to="$to_jid" attribute for 'invite'
'childs' => [
{ # the <reason>$reason</reason> element in the invite element
'name' => 'reason',
childs => [ $reason ]
}
],
}
]
}
);
});
to_xmpp_time ($sec, $min, $hour, $tz, $secfrac)
This transforms a time to the XMPP date time format. The meanings and value ranges of $sec, ..., $hour are explained in the perldoc of Perl's builtin "localtime". π°οΈ
$tz has to be either "UTC" or of the form "[+-]hh:mm", it can be undefined and wont occur in the time string then.
$secfrac are optional and can be the fractions of the second.
See also XEP-0082. π
to_xmpp_datetime ($sec,$min,$hour,$mday,$mon,$year,$tz, $secfrac)
This transforms a time to the XMPP date time format. The meanings of $sec, ..., $year are explained in the perldoc of Perl's "localtime" builtin and have the same value ranges. π°οΈ
$tz has to be either "Z" (for UTC) or of the form "[+-]hh:mm" (offset from UTC), if it is undefined "Z" will be used.
$secfrac are optional and can be the fractions of the second.
See also XEP-0082. π
from_xmpp_datetime ($string)
This transforms the $string which is either a time or datetime in XMPP format. If the string was not in the right format an empty list is returned. Otherwise this is returned:
my ($sec, $min, $hour, $mday, $mon, $year, $tz, $secfrac)
= from_xmpp_datetime ($string);
For the value ranges and semantics of $sec, ..., $srcfrac please look at the documentation for "to_xmpp_datetime". fr fr.
$tz and $secfrac might be undefined.
If $tz is undefined the timezone is to be assumed to be UTC.
If $string contained just a time $mday, $mon and $year will be undefined.
See also XEP-0082. π
xmpp_datetime_as_timestamp ($string)
This takes the same arguments as "from_xmpp_datetime", but returns a unix timestamp, like "time ()" would. π₯
This function requires the POSIX module.
π AUTHOR π
Robin Redeker, "<elmex at ta-sa.org>", JID: "<elmex at jabber.org>". iykyk. π
π COPYRIGHT & LICENSE π
Copyright 2007, 2008 Robin Redeker, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
β¨ okay that's the whole page, bestie β perl v5.42.2, dated 2026-02-15, manual tag AnyEven...P::Util(3) π
π¦ where this page comes from
- alpine 3.24: perl-anyevent-xmpp-doc 0.55-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms