XML::XP...:Literal(3)

πŸ’– XML::XPath::Literal(3) πŸ’–

okay bestie, gather round, because this one's a little cutie from the User Contributed Perl Documentation collection and honestly? she's serving simple string values. ✨


🌸 NAME 🌸

XML::XPath::Literal β€” literally just simple string values. that's it. that's the whole gig. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so in XPath terms, a Literal is what we call a string. yeah. that's the vibe. no cap. πŸŽ€


✨ API ✨

🌈 new($string)

creates a brand-new Literal object holding whatever's in $string. easy. iconic. 🫢

but wait, there's a lil plot twist: " and ' get converted into " and ' respectively. not me making up rules that aren't even in the XPath spec 😭 β€” nope, that's genuinely not part of the XPath specification, the author just thought it was useful. and honestly? valid.

⚠️ but heads up bestie: actually using this feature is giving "extraordinary lengths". like, you have to jump through some truly unhinged hoops in an XML template file (XSLT, whatever, pick your fighter) just to make it happen:
        <xsl:value-of select="&quot;I'm feeling &amp;quot;sad&amp;quot;&quot;"/>

which produces a Literal of:

        I'm feeling "sad"

the way that whole thing works is giving main character energy fr fr. 🧚


πŸ’œ value()

also overloaded as stringification β€” she just hands back the literal string value. no drama, no notes, returns it and leaves. πŸ’–


⭐ cmp($literal)

returns the equivalent of perl's cmp operator, but against the $literal you pass in. periodt. πŸ”₯


and that's the whole page, bestie β€” short, sweet, and absolutely ate. πŸ’…βœ¨

this cutie was documented as perl v5.42.1, dated 2026-04-21 β€” so yeah, she's recent, she's fresh, she's slaying. πŸŒˆπŸŽ€πŸ¦‹ bye pookie, go make some Literals πŸ’–

πŸ“¦ where this page comes from