As part of today's work on my OSCON slides, I've put XML::Literal 0.01 on CPAN:
# This is not a source filter: it just augments glob().
use XML::Simple;
use XML::Literal \&XMLin;
# Simple element
my $xml1 = <hr/>;
# With variable interpolation
my $xml2 = <input value='$ARGV[0]' />;
# With an extra pair of angle brackets
my $xml3 = < <a href='/'> Some Text </a> >;
# With escaped angle brackets
my $xml4 = <a href='/'\> Some Text \</a>;
# Direct call to the xml-building glob'' constructor
my $xml5 = glob'
<p><em>
Some Text
</em></p>
';
# This does not look like XML, so it's still shell glob
my @files = <*.*>;
Of course, having it simply construct hashes via XML::Simple is not very interesting. More fun is to use it to construct XML patterns and composable, self-validating fragments -- more (ab)uses are left as exercise for the reader. :-)

Recent Comments