[28289] in Perl-Users-Digest
Perl-Users Digest, Issue: 9653 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 27 11:10:14 2006
Date: Sun, 27 Aug 2006 08:10:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 27 Aug 2006 Volume: 10 Number: 9653
Today's topics:
Re: regular expression variables under debugger - SOME <wlcna@nospam.com>
Re: regular expression variables under debugger - SOME <klaus03@gmail.com>
Re: regular expression variables under debugger - SOME <mgarrish@gmail.com>
Re: regular expression variables under debugger - SOME <tadmc@augustmail.com>
Re: regular expression variables under debugger - SOME <David.Squire@no.spam.from.here.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 27 Aug 2006 09:38:43 GMT
From: "wlcna" <wlcna@nospam.com>
Subject: Re: regular expression variables under debugger - SOME RESOLUTION!
Message-Id: <DKdIg.12350$1f6.1942@newssvr27.news.prodigy.net>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x71wr23bjc.fsf@mail.sysarch.com...
> you are beyond clueless. please leave and go learn python. they need
> to
> be told about google groups. and in case you didn't know, google
> didn't
> invent usenet nor even searching usenet. but of course you know all
> about google and perl bugs that don't exist.
>
Yesh, I fanshy I know alot because I've heard of google. Yesh I do! I
fanshy that google created usenet, yesh I do!
Oh, man. Honestly I'm sorry this discussion is so bad...
First, let me close here by saying I do apologize for calling you a name
several posts ago. Seriously, I apologize for that. Very bad form,
sorry, just let this get the better of me.
But in parting I'd like to point out my beefs as a matter of setting the
record straight and trying to clear the air. Actually, before putting
this list together I hadn't actually realized that you were probably the
one presenting the biggest problem to me out here! I remembered the one
thing, but I had ascribed one of the other problems to someone else. I
thought there was at least one other involved with the below points, but
your name kept popping up when I reviewed the posts. Anyways...
1. THE PROGRAM WAS DOING DIFFERENT THINGS UNDER THE DEBUGGER THAN NOT
UNDER THE DEBUGGER. This was stated many times by me and it is a
self-evident piece of important information that should tell you alot
about what I'm seeing, and almost every single one of those
participating in the thread totally ignored that or just never read it
in the first place.
2. (You actually did this one.) THE PROBLEM WAS IN THE STRINGS COMING
BACK FROM THE XML LIBRARY and someone (actually you!) tell me that I'm
dumb for not reproducing the problem by just typing in the string!! If
I could have reproduced the problem that way I would have. In fact,
that was the premise of my original post, I assumed I *could* do that,
and as stated, THAT DIDN'T DO IT! So, clearly pointed out that it
didn't work that way and if I typed it or copy/pasted it, things worked
fine. In fact, if I got the "identical" string from the HTML library
also, things were fine. Only from the XML library did the problem
appear and this was stated. And there was something I found going on in
a utf8 library with that string that wouldn't happen in the other
scenarios. Again, just blithely ignored.
3. (And of course, you did this one.) YOU TELL ME THE CODE DOES NOT
SHOW ANYTHING BECAUSE I DIDN'T PRINT A VARIABLE FOR YOU. Dude, why not
run the code yourself and print whatever variables you like, isn't that
why I posted it?? So you guys ask for code so you can try things out
for yourelves, I give that plus debugger executions showing a bit about
the problem, and you have a fit because the little debugger context I
show is not done how you'd prefer. The idea of posting the code was not
to provoke analysis but to get people to try it. So, pretty dense here.
If you really didn't want to install it (only takes 30 seconds), why not
say, "Dude, I don't want to install this crap, can you show me a
debugger run printing $str?" Instead you start some silly personal
attack.
4. I think you and like what 2 others telling me over and over again to
check the regex succeeded before accessing $1. That's a fine coding tip
or whatever it's supposed to be but it was entirely missing the point.
The issue was to show the problem happening and that was easiest done
WITH KNOWN MATCHING INPUTS. I.e. I'd prefer to just type it in and that
was the idea of the original code. Show a known matching input, show
that nothing comes back when it should. I had already stated
essentially that the regex is failing under the debugger but not in the
regular run. So what you guys are telling me is, well, this is stupid,
why don't you check if the regex is failing when you're seeing that it's
not working. I know it was failing in the debugger, and not in the
regular run with the identical inputs and this was the issue being
identified!
5. Telling me to use strict and use warnings (I don't think you ever
did this). I actually had use strict in there at the top of the file,
but I was putting only the really relevant clip of the file for people
to reproduce.
So anyway, if someone can tell me how I've been dense, which has been
said, I'd appreciate it, because I don't think I've been dense about
anything here, but anyway, I do apologize for the excessive rudeness.
------------------------------
Date: 27 Aug 2006 03:32:30 -0700
From: "Klaus" <klaus03@gmail.com>
Subject: Re: regular expression variables under debugger - SOME RESOLUTION!
Message-Id: <1156674750.125541.128030@h48g2000cwc.googlegroups.com>
wlcna wrote:
> 1. THE PROGRAM WAS DOING DIFFERENT THINGS UNDER THE DEBUGGER
> THAN NOT UNDER THE DEBUGGER.
This does not change the way you resolve your problem, that is by
reducing the complexity of your original program step-by-step until you
can reproduce the problem in a small but complete program.
See my response from 25/08/2006 at 08:17 pm
http://groups.google.fr/group/comp.lang.perl.misc/browse_frm/thread/4829d88d5e36830b/?hl=en&
> 2. THE PROBLEM WAS IN THE STRINGS COMING
> BACK FROM THE XML LIBRARY
That's irrelevant information.
wlcna wrote:
> I have a program I was running through the debugger that had a usage
> like this (this is not the code but similar):
>
> 1: my $str = "hello there yes i am here";
> 2: $str =~ /([a-z]*)s/;
> 3: $yes = $1;
>
> [...] the debugger [...] tells me that $1 is "undef"
> [...] *NOT IN THE DEBUGGER* and everything is normal,
> and I check by doing old-fashioned print statements. $yes is "yes" as
> expected.
The info >>$yes is "yes"<< is misleading information.
The problem is that for given a scalar "$str", the resulting "$1" after
the regular expression "/([a-z]*)s/" is not the same with and without
debugger
> 3. YOU TELL ME THE CODE DOES NOT
> SHOW ANYTHING BECAUSE I DIDN'T PRINT
> A VARIABLE FOR YOU.
Then add some prints to your code. Here is how I would do it:
print '$str = ', unpack('H*', $str), "\n";
$str =~ /([a-z]*)s/;
print '$1 = ', unpack('H*', $1), "\n";
> 4. I think you and like what 2 others telling me over and over again to
> check the regex succeeded before accessing $1.
Here is how I would check the regex before accessing $1:
$str =~ /([a-z]*)s/ or die qq{No match in '$str'};
> 5. Telling me to use strict and use warnings
Good advice
------------------------------
Date: 27 Aug 2006 05:44:26 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: regular expression variables under debugger - SOME RESOLUTION!
Message-Id: <1156682666.761161.156710@i3g2000cwc.googlegroups.com>
wlcna wrote:
> "Matt Garrish" <mgarrish@gmail.com> wrote in message
> news:1156644609.633862.89090@m73g2000cwd.googlegroups.com...
> >
> > Have you never heard of providing context for your posts? Why do you
> > think your problem is so profoundly interesting to anyone that they
> > should go looking for your code, which in this case was pointless and
> > proved nothing.
> >
>
> Well, I think it *would* be interesting if a regular expression that one
> knows ahead of time *does* match and matches fine when in non-debugging
> mode, but it does something completely different under the debugger,
> gee, silly me, I thought that was interesting.
>
Right, and we're all supposed to take your word for it, because
obviously you're so profoundly intelligent that it couldn't be your own
misunderstanding of what is going on in your program. Stop the presses
everyone, someone doesn't know how to use the debugger!
> I still think it is, and if I see it again, I will post back because
> this is not the first time I've seen something like that, as I
> originally indicated.
>
> And I did post the code that reproduced the problem for me, what like 3
> or 4 times?? At first, I didn't have the exact code, and when that was
> the case I said so and said I'd post it as soon as I had it because I
> thought I had hit upon the actual problem area. And I figured out what
> the problem was with no help from you all and I posted the code that
> reproduced the problem.
>
> And what did the folks out here say. First, I don't want to install any
> XML:: library. Second, what I posted was not minimal enough, when in
> fact it was, well at least give or take a line or two. Third, that I
> needed use strict and use warnings, when these things of course had
> nothing whatsoever to do with the issue.
>
You did nothing of the sort. You posted a lot of useless code and
debugging output that proved nothing, as others showed you. You're
hardly one to judge what will and will not help debug your problem when
your understanding of perl isn't very deep. It's your silly assertions
like your regular expression never failing that make people's eyes
roll. Why should anyone here make any effort to help you when you won't
even take the minimal steps necessary to prove that it's not your
poorly written code that's to blame?
>
> Your "sky is falling" item is completely ridiculous as I don't think at
> any point I was begging anyone out here for help, simply pointing out
> odd behavior and trying to get comments. I think I can safely say that
> at no point was I at risk of receiving help here and I wasn't really
> asking for help, more like "serving notice" of a problem and getting
> comments about what people thought about it (like it it lightning
> striking or just par for the course).
>
And that's why you've irritated everyone here. I would suggest you
actually read the story of chicken little before you presume to
understand how it applies to you. Because you got bopped on the head by
an acorn, or in this case because you failed to understand what was
going on with your program, does not mean there is any imminent
catastrophe worth investigating. Before wasting people's time with
pointless inquiries after your own incompetence please take the time to
ensure that it's not just an acorn. 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.
Matt
------------------------------
Date: Sun, 27 Aug 2006 08:11:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regular expression variables under debugger - SOME RESOLUTION!
Message-Id: <slrnef36gr.8dq.tadmc@magna.augustmail.com>
wlcna <wlcna@nospam.com> wrote:
> First, let me close here by saying I do apologize for calling you a name
> several posts ago. Seriously, I apologize for that. Very bad form,
> sorry, just let this get the better of me.
If only folks had been cautioned against such things!
> So anyway, if someone can tell me how I've been dense, which has been
> said, I'd appreciate it, because I don't think I've been dense about
> anything here,
Have you seen the Posting Guidelines that are posted here frequently?
Count to ten before composing a followup when you are upset
Count to ten after composing and before posting when you are upset
<g>
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 27 Aug 2006 14:54:02 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: regular expression variables under debugger - SOME RESOLUTION!
Message-Id: <ecs85q$edq$1@gemini.csx.cam.ac.uk>
Matt Garrish wrote:
> wlcna wrote:
>
>> "Matt Garrish" <mgarrish@gmail.com> wrote in message
>> news:1156644609.633862.89090@m73g2000cwd.googlegroups.com...
>>> Have you never heard of providing context for your posts? Why do you
>>> think your problem is so profoundly interesting to anyone that they
>>> should go looking for your code, which in this case was pointless and
>>> proved nothing.
>>>
>> Well, I think it *would* be interesting if a regular expression that one
>> knows ahead of time *does* match and matches fine when in non-debugging
>> mode, but it does something completely different under the debugger,
>> gee, silly me, I thought that was interesting.
>>
> 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! News: U.S. News
testPart: <Yahoo! News: U.S. >, testWhole: <Yahoo! News: U.S. News>
~/tmp (davids : dms54)
Aug 27 - 14:31 %
./test_with_XML::TreeBuilder.pl
$str = Yahoo! News: U.S. News
testPart: <Yahoo! News: U.S. >, testWhole: <Yahoo! News: 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! News: 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! News: 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! News: U.S. >, testWhole: <Yahoo! News: 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! News: 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
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9653
***************************************