You don't report a baseless problem
and then expect people to run around trying to reproduce it for you
because you're too lazy to write a program that exhibits it. If there
is a real problem in perl everyone should be able to reproduce it. If
you can't write a minimal script to do this then, gee, perhaps you
haven't really found a bug in perl.
This is not true. wlcna *did* post scripts that exhibit a problem. I
have run them (after adding checks on regex matches and more prints),
and there *is* weirdness under the debugger in one case and not the
other, which would appear to be module-related. This weirdness does not
appear when the scripts are run without the debugger.
Below I include my versions of the scripts, and a transcript showing
them run with and without the debugger. When using XML::TreeBuilder, I
get the sort of "Out of memory!" that wlcna reported.
---- Begin test_with_HTML::TreeBuilder.pl ----
#!/usr/bin/perl
use strict;
use warnings;
# HTML version
use LWP::Simple;
use HTML::TreeBuilder;
my $strUrl = '
http://rss.news.yahoo.com/rss/us';
my $strHtml = get( $strUrl );
my $t = new HTML::TreeBuilder;
$t->parse( $strHtml );
$t->eof;
my $str = $t->content->[0]->content->[0]->as_text;
print "\$str = $str\n";
($str =~ /(.*)news/i) or warn "No match!\n";
my $testPart = $1;
my $testWhole = $&;
my $breakpoint = 3;
print "testPart: <$testPart>, testWhole: <$testWhole>\n";
---- End test_with_HTML::TreeBuilder.pl ----
---- Begin test_with_XML::TreeBuilder.pl ----
#!/usr/bin/perl
use strict;
use warnings;
# *SECOND* XML and RSS VERSION
use LWP::Simple;
use XML::TreeBuilder;
my $strUrl = '
http://rss.news.yahoo.com/rss/us';
# retrieve
my $strHtml = get( $strUrl );
# parse the data retrieved.
my $t = new XML::TreeBuilder;
$t->parse( $strHtml );
$t->eof;
my $str = $t->content->[1]->content->[1]->as_text;
print "\$str = $str\n";
($str =~ /(.*)news/i) or warn "No match!\n";
my $testPart = $1;
my $testWhole = $&;
my $breakpoint = 3;
print "testPart: <$testPart>, testWhole: <$testWhole>\n";
---- End test_with_XML::TreeBuilder.pl ----
---- Begin Transcript ----
~/tmp (davids : dms54)
Aug 27 - 14:31 % ./test_with_HTML::TreeBuilder.pl
$str = Yahoo! U.S. News
testPart: <Yahoo! U.S. >, testWhole: <Yahoo! U.S. News>
~/tmp (davids : dms54)
Aug 27 - 14:31 %
../test_with_XML::TreeBuilder.pl
$str = Yahoo! U.S. News
testPart: <Yahoo! U.S. >, testWhole: <Yahoo! U.S. News>
~/tmp (davids : dms54)
Aug 27 - 14:31 % perl -d
test_with_HTML::TreeBuilder.pl
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main:
test_with_HTML::TreeBuilder.pl:11):
11: my $strUrl = '
http://rss.news.yahoo.com/rss/us';
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:13):
13: my $strHtml = get( $strUrl );
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:15):
15: my $t = new HTML::TreeBuilder;
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:16):
16: $t->parse( $strHtml );
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:17):
17: $t->eof;
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:19):
19: my $str = $t->content->[0]->content->[0]->as_text;
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:20):
20: print "\$str = $str\n";
DB<1> n
$str = Yahoo! U.S. News
main:
test_with_HTML::TreeBuilder.pl:21):
21: ($str =~ /(.*)news/i) or warn "No match!\n";
DB<1> n
main:
test_with_HTML::TreeBuilder.pl:22):
22: my $testPart = $1;
DB<1> print $1
Yahoo! U.S.
DB<2> n
main:
test_with_HTML::TreeBuilder.pl:23):
23: my $testWhole = $&;
DB<2> n
main:
test_with_HTML::TreeBuilder.pl:25):
25: my $breakpoint = 3;
DB<2> n
main:
test_with_HTML::TreeBuilder.pl:26):
26: print "testPart: <$testPart>, testWhole: <$testWhole>\n";
DB<2> n
testPart: <Yahoo! U.S. >, testWhole: <Yahoo! U.S. News>
Debugged 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
~/tmp (davids : dms54)
Aug 27 - 14:32 % perl -d
test_with_XML::TreeBuilder.pl
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main:
test_with_XML::TreeBuilder.pl:10):
10: my $strUrl = '
http://rss.news.yahoo.com/rss/us';
DB<1> n
main:
test_with_XML::TreeBuilder.pl:13):
13: my $strHtml = get( $strUrl );
DB<1> n
main:
test_with_XML::TreeBuilder.pl:16):
16: my $t = new XML::TreeBuilder;
DB<1> n
main:
test_with_XML::TreeBuilder.pl:17):
17: $t->parse( $strHtml );
DB<1> n
main:
test_with_XML::TreeBuilder.pl:18):
18: $t->eof;
DB<1> n
main:
test_with_XML::TreeBuilder.pl:20):
20: my $str = $t->content->[1]->content->[1]->as_text;
DB<1> n
main:
test_with_XML::TreeBuilder.pl:21):
21: print "\$str = $str\n";
DB<1> n
$str = Yahoo! U.S. News
main:
test_with_XML::TreeBuilder.pl:22):
22: ($str =~ /(.*)news/i) or warn "No match!\n";
DB<1> n
perl(4560) malloc: *** vm_allocate(size=4291080192) failed (error code=3)
perl(4560) malloc: *** error: can't allocate region
perl(4560) malloc: *** set a breakpoint in szone_error to debug
Out of memory!
Debugged 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<1>
---- End Transcript ----
---- Begin version details ----
~/tmp (davids : dms54)
Aug 27 - 14:40 % perl -v
This is perl, v5.8.6 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
# I downloaded and installed all the modules used from CPAN yesterday (I
have just reinstalled this system).
---- End version details ----
I have also tested a version where $str is fixed and no modules are
used. It has no weirdness, just as seen when using HTML::TreeBuilder.
I'll post it if you like.
Now, I know next to nothing about using the Perl debugger, but the
behaviour above is not what I would have expected. If this is because I
don't know how to use the debugger, I will be glad to be informed of how
to do it properly.
I think that the lesson of this thread is that both sides of the
discussion got angry early, with the result that very few people
actually read deeply or tried things. Once the insults and name-calling
starts, the chances of analysis and help drop dramatically. There are
lessons for both sides here.
First and foremost, if you *have* done tests to eliminate cases such as
regexes not matching, leave them in the minimal example script so that
folks don't leap on that common newbie error as the likely explanation
for the problem. Likewise for including "use strict; use warnings;".
Getting snippy about this sort of thing results in people not reading
your later posts.
DS