Why the same script have different behavior when executed in Normalor Debug mode?

D

djslls

I'm a beginner in perl. I met a problem today. I don't know why. Here
is the scenario:

Test on Windows XP, Perl v5.8.6, Locale: English

#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Text::parseWords qw(parse_line);

my $teststr="123#abc#xyz";
$teststr=decode("ascii",$teststr); ###(1) pay attention here

my @testarray=parse_line("#",0,$teststr);
my $test=$testarray[0];

print $test;

in Normal executing mode, I get "123" in output;
however, when debugging, I type "p $test" just before the last line, I
get nothing. It should be "123".

What happens here? Is there anybody know something about it?

Thanks in advance!

ps. if we comment the decode line, the script will work well in both
mode.
 
D

djslls

After refreshing perl to v5.10, the problem does not exist any more.

Thanks, Bob


I'm a beginner in perl. I met a problem today. I don't know why. Here
is the scenario:
Test on Windows XP, Perl v5.8.6, Locale: English
#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Text::parseWords qw(parse_line);
my $teststr="123#abc#xyz";
$teststr=decode("ascii",$teststr); ###(1) pay attention here
my @testarray=parse_line("#",0,$teststr);
my $test=$testarray[0];
print $test;
in Normal executing mode, I get "123" in output;
however, when debugging, I type "p $test" just before the last line, I
get nothing. It should be "123".
What happens here? Is there anybody know something about it?

Well, when I try your program verbatim, it works fine -- "p $test" at
the indicated point gives "123":

c:\junk>perl -d junk605.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main::(junk605.pl:7): my $teststr="123#abc#xyz";

DB<1> n
main::(junk605.pl:8): $teststr=decode("ascii",$teststr); ###(1) pay
attentio
n here

DB<1> n
main::(junk605.pl:10): my @testarray=parse_line("#",0,$teststr);

DB<1> n
main::(junk605.pl:11): my $test=$testarray[0];

DB<1> n
main::(junk605.pl:13): print $test;

DB<1> p $test
123

DB<2> n
123Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.

DB<2> q

c:\junk>perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1004 [287188] provided by ActiveStatehttp://www.ActiveState.com
Built Sep 3 2008 13:16:37

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser athttp://www.perl.org/, the Perl Home Page.

c:\junk>


Thanks in advance!
ps. if we comment the decode line, the script will work well in both
mode.

HTH.
 
E

Eric Pozharski

On 2009-03-03 said:
#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Text::parseWords qw(parse_line);

my $teststr="123#abc#xyz";
$teststr=decode("ascii",$teststr); ###(1) pay attention here

my @testarray=parse_line("#",0,$teststr);
my $test=$testarray[0];

print $test;

in Normal executing mode, I get "123" in output;
however, when debugging, I type "p $test" just before the last line, I
get nothing. It should be "123".

(wild guess) Consider adding explicit newline (C<"\n">) (there're many
ways to do this in Perl though). That's possible, that your output
happens to overwritten with debugger's.

*CUT*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top