kgullekson has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I'm running a script which uses XML::Parser to parse an XML file. I'm seeing some weird stuff when I run in debug. Why do the contents of my $data variable seem to disappear after I strip off tabs?
main::char_handler(./test.pl:137): 137: ($p, $data) = @_; DB<21> p $data PositionFairValueBase DB<22> x $data 0 'PositionFairValueBase' DB<23> s main::char_handler(./test.pl:140): 140: $data =~ s/\t//g; DB<23> x $data 0 ' ' DB<24>

Thanks!

Replies are listed 'Best First'.
Re: Strange behaviour of XML char handler
by jethro (Monsignor) on Feb 21, 2009 at 00:23 UTC

    Your problem lies with understanding the debugger. If you do a step it executes the previous shown line and shows you the next. For example

    > cat t7.pl #!/usr/bin/perl -w $t=1; $t=5; $t=10; > perl -d t7.pl main::(t7.pl:7): my $t=1; DB<1> x $t 0 undef DB<2> s main::(t7.pl:8): $t=5; DB<2> x $t 0 1 DB<3> q

    So the line ($p, $data) = @_; is the one that changes your var

      Thanks for the wisdom!