in reply to Re^7: Not able to replace element value using XML::Twig
in thread Not able to replace element value using XML::Twig

I was able to locate Twig.pm and it does have the print_to_file function.

sub print_to_file { my( $t, $filename)= (shift, shift); open( TWIG_PRINT_TO_FILE, ">$filename") or croak "cannot create fi +le $filename: $!"; $t->print( \*TWIG_PRINT_TO_FILE, @_); close TWIG_PRINT_TO_FILE; return $t; }

Twig_pm.slow,v 1.303 2006/05/26 08:07:14
This is the Twig version in my system but the code is available in the library

Replies are listed 'Best First'.
Re^9: Not able to replace element value using XML::Twig
by jethro (Monsignor) on Feb 01, 2010 at 01:14 UTC

    Strange. You might try the following:

    perl -Dt -m"XML::Twig" -e ''

    This only works if your perl is compiled with debugging enabled, but if it is, you will see a lot of debugging output, most lines preceded with the filename of the module perl is executing. Check that the Twig.pm you found is the Twig.pm named in most of these lines

    If it is, you also might try the following command:

    perl -Dx -m"XML::Twig" -e '' 2>&1 | grep print_to # should print: SUB XML::Twig::print_to_file = {

    This shows that the subroutine print_to_file is really parsed

    If you get both of above results, you might check the source code of your script whether there are invisible characters or a typo. You also could test this by copy-and-pasting the following line which should produce a 'cannot create file' error:

    perl -m"XML::Twig" -e '$twig=XML::Twig->new(); $twig->print_to_file() +'