Subject: | set_pretty_print("indented_c") -> Undefined subroutine &Text::Wrap::wrap |
Date: | Fri, 30 Sep 2011 23:42:37 +0200 (MEST) |
To: | bug-XML-Twig [...] rt.cpan.org |
From: | Martin Str|mberg <ams [...] ludd.ltu.se> |
Hello.
Test program (twig_bug1.pl):
#!/usr/bin/perl -w
use strict;
use XML::Twig;
my $show_bug = shift;
my $t= XML::Twig->new();
$t->parse( '<d><title>title</title><para>p 1</para><para>p 2</para></d>');
if( $show_bug ) {
$t->set_pretty_print("indented_c");
} else {
$t->set_pretty_print("wrapped");
}
$t->print;
End of test program.
Run as "./twig_bug1.pl" -> all is fine.
Run as "./twig_bug1.pl Oops" ->
Undefined subroutine &Text::Wrap::wrap called at /usr/share/perl5/XML/Twig.pm line 7729.
Patch:
diff -ru XML.org/Twig.pm XML/Twig.pm
--- XML.org/Twig.pm 2011-09-30 23:13:55.000000000 +0200
+++ XML/Twig.pm 2011-09-30 23:23:14.000000000 +0200
@@ -7682,7 +7682,7 @@
{ croak "invalid pretty print style '$style'" unless( exists $pretty_print_style{$style});
$pretty= $pretty_print_style{$style};
}
- if( ($pretty == $WRAPPED) || ($pretty == $INDENTEDA) )
+ if( ($pretty == $WRAPPED) || ($pretty == $INDENTEDA) || ($pretty == $INDENTEDC))
{ XML::Twig::_use( 'Text::Wrap') or croak( "Text::Wrap not available, cannot use 'wrapped' style"); }
return $old_pretty;
}
It shouldn't matter but I'm running Debian lenny == 5.0.8, which uses
"perl5 (revision 5 version 10 subversion 0)" on
"Linux hume 2.6.26-2-amd64 #1 SMP Mon Sep 19 06:13:12 UTC 2011 x86_64 GNU/Linux"
XML::Twig from Debian is 3.32, but 3.39 from cpan.org has the same bug.
Thank you for XML::Twig and perl.
--
MartinS