Acme-PerlML
view release on metacpan or search on metacpan
lib/Acme/PerlML.pm view on Meta::CPAN
sub code2xml {
my $Document = PPI::Document->new(\$_[0]);
my $SAX = Perl::SAX->new;
$SAX->parse( $Document );
return ${ $SAX->{Output} };
}
# Allow people to use Acme::PerlML () sanely
sub import {
## This code isn't Acme::Bleach evil yet as that would be teh hard to debug
open 0 or die "Couldn't open $0: $!";
(my $code = join "", <0>) =~ s/(.*)^\s*use\s+Acme::PerlML\s*;\n//sm;
# Already converted
if ( $code =~ /^<document>/m ) {
eval xml2code($code);
exit();
}
my $xml = code2xml($code) or die "Failed to convert Perl to XML";
( run in 0.246 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )