XML::C...::Util(3pm)
π XML::Compile::Util β utility routines for XML::Compile components π
okay so hi bestie!! β¨ this is XML::C...::Util from the 3pm section of your manual pages, and it's literally just a lil grab-bag of helper routines that the various XML::Compile components use. They're kind of unrelated to each other?? like a group chat where nobody knows how everyone met. but they're all useful, so. π«Ά
π INHERITANCE
XML::Compile::Util- is an
Exporterπ
- is an
so yeah she exports stuff. that's the whole personality trait. iconic.
β¨ SYNOPSIS
use XML::Compile::Util;
my $node_type = pack_type $ns, $localname;
my ($ns, $localname) = unpack_type $node_type;
πΈ DESCRIPTION
The functions in this package get used by all sorts of XML::Compile components, and ngl those components might have zero to do with each other. It's giving "found family" energy fr fr. π
π FUNCTIONS
π§ Constants
These URIs are exported as constants, so you don't have to sit there typing the same giant URI over and over like a clown: XMLNS, SCHEMA1999, SCHEMA2000, SCHEMA2001, and SCHEMA2001i. ur welcome bestie π
π¦ Packing
pack_id($ns, $id)β squishes those two args into one compact string representation of the node id. π«Ά
example:
print pack_id 'http://my-ns', 'my-id';
# shows: http://my-ns#my-id
pack_type( [$ns], $localname )β turns the args into one compact string representation of the node type. and listen: when$nsisn't there, or it'sundef, or it's an empty string, then no namespace is presumed and no curly-brace part gets made. periodt. π
example:
print pack_type 'http://my-ns', 'my-type';
# shows: {http://my-ns}my-type
print pack_type 'my-type';
print pack_type undef, 'my-type';
print pack_type '', 'my-type';
# all three show: my-type
unpack_id($string)β returns aLISTof two elements: the name-space and the id, exactly as included in$string. that$stringhas to be compatible with whateverpack_id()spits out, no cap. πunpack_type($string)β returns aLISTof two elements: the name-space and the localname, as included in$string. again,$stringmust be compatible with the result ofpack_type(). when there's no name-space present, an empty string is used. π¦
π Other
add_duration( $duration, [$time] )β[1.44]adds the$durationto the$time(which defaults to'now'). heads up though: this is an expensive operation π in many casesduration2secs()produces useful results as well, so consider that before you go spending all your CPU.
example:
my $now = time;
my $deadline = add_duration 'P1M', $now; # deadline in 1 month
duration2secs($duration)β[1.44]translates any format into seconds. here's an example of a valid duration:"-PT1M30.5S"β±οΈ average month and year lengths are used, so if you need more precise calculations, then useadd_duration()instead. iykyk.even_elements(LIST)β returns the even-numbered elements from theLIST. β¨odd_elements(LIST)β returns the odd-numbered elements from theLIST. β¨type_of_node($node)β translates anXML::LibXML::Nodeinto a packed type. π
π SEE ALSO
This module is part of XML-Compile distribution version 1.64, built on October 21, 2024. Website: http://perl.overmeer.net/xml-compile/ β go look, bestie, it's right there. π₯
π LICENSE
Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog. π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/ π
okay and for the cute lil sign-off: this whole vibe is perl v5.40.0, dated 2024-10-27, and the manual page name is XML::C...::Util(3pm) in case you forgot where you were. slay, go pack some types πβ¨π
π¦ where this page comes from
- debian trixie: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libxml-compile-perl 1.64-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms