[26056] in Perl-Users-Digest
Perl-Users Digest, Issue: 8264 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 21 10:59:40 2005
Date: Wed, 20 Jul 2005 15:05:05 -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 Wed, 20 Jul 2005 Volume: 10 Number: 8264
Today's topics:
Re: ithreads & memory <No_4@dsl.pipex.com>
Re: problem using both Memoize::Expire and DB_File <dejanews@email.com>
Re: Regex (?(?{CODE})) has too many branches <spam-block-@-SEE-MY-SIG.com>
Re: Tk: Text works with TIE, Scrolled doesn't <stfhostf@kartos.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 20 Jul 2005 21:18:33 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: ithreads & memory
Message-Id: <9dqdnTaGSskBLEPfRVnyjA@pipex.net>
xhoster@gmail.com wrote:
>
> On linux, too, the in-the-loop "my" makes it much more memory efficient.
> I just can't figure out why.
Adding:
$th_n = undef;
after the detach also stops it gathering memory. This implies that what
your original code did was to continually add threads to $th_n. It did
detach each one after using it, but the documentation for detach doesn't
mention anything about destroying it, or its resources. It implies that
what happens is that the thread is just detached from its parent - a bit
like a fork() - but still exists, albeit unusefully in the example.
Specfically removing $th_n, or implicilty removing it by declaring it
with my in the loop, does destroy all threads.
Presumably it is possible to detach threads and let them continue to run?
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
Date: Wed, 20 Jul 2005 20:06:10 GMT
From: samwyse <dejanews@email.com>
Subject: Re: problem using both Memoize::Expire and DB_File
Message-Id: <S8yDe.924$Ok6.598@newssvr29.news.prodigy.net>
samwyse wrote:
> Following the example in the Memoize::Expire perldoc, I tried to set up
> a disk-backed cache with an expiration time. It doesn't seem to want to
> work for me. Below is my test script and its results. Subroutine
> 'test0' is memoized via a simple cache, 'test1' uses a disk-backed
> cache, 'test2' uses an expiring cache, and 'test3' uses both. The test
> program calls each subroutine twice and the program itself is run twice;
> the problem is evident during the first pass of the second run, where
> 'test1' doesn't get invoked (as expected, since the value is found in
> the disk-based cache) but 'test3' is invoked. (Specifically, the
> message "inside test3()" shouldn't be seen in loop 1 of the second run.)
>
> Using 'od -c' against the db files indicates that the data for 'test3'
> is never written to disk. Google doesn't seem to turn anything up,
> except for lots of copies of the perldoc. I'm running this on a Sun
> under Solaris 2.6. My Perl version is 5.6.X (Sorry, I forgot to note
> the exact value and I'm at home right now.), and upgrading to 5.8 would
> be difficult on this server.
>
> Later today I plan to dig into the internals of Memoize::Expire. Until
> then, thanks for any assistance.
OK, I've confirmed that the same behaivor exists for Perl 5.8.6 running
under Cygwin. It also doesn't seem to matter if I use DB_File or
Memoize::AnyDBM_File. I guess that I'll be firing off a note to the
package maintainer.
------------------------------
Date: Wed, 20 Jul 2005 19:06:48 +0100
From: James Taylor <spam-block-@-SEE-MY-SIG.com>
Subject: Re: Regex (?(?{CODE})) has too many branches
Message-Id: <ant2018480e6fNdQ@riscpc.jtnet>
In article <slrndds09k.7fo.abigail@alexandra.abigail.nl>,
Abigail <abigail@abigail.nl> wrote:
>
> James Taylor wrote:
> >
> > my ($table) = $page =~ m{
> > (?> <table\b.*?> (.*?) </table> ) # Get table
> > (?(?{
> > $1 !~ /<table\b/i && # Mustn't contain a table
> > $1 =~ /\bclass="whiteHeading"/i # Must have white headings
> > }) | _FAIL_ )
> > }six;
> >
> > Unfortunately, this generates the following error:
> >
> > /\bclass="whiteHeading"/: Switch (?(condition)... contains too
> > many branches at myprog line 66.
>
>
> The regex engine is not re-entrant,
[snip]
> Use index().
Aha! Thanks for that. After spending some time trying to work
out why index() wasn't working, I eventually tried index
without brackets and got the following to compile and run:
my ($table) = $page =~ m{
# Get a table without backtracking
(?> <table\b.*?> (.*?) </table> )
# Put a lowercase copy of its content in $content
(?{ local $content = lc $1; })
# Check it does not contain another table
(?(?{ -1 == index $content, '<table' }) | --FAIL-- )
# Debug message
(?{ print "Top level table found\n"; })
# Check it does contain a white heading
(?(?{ -1 != index $content, 'class="whiteHeading"' }) | --FAIL-- )
# Debug message
(?{ print "Matched\n" })
}six;
This prints "Top level table found\n" 25 times and falls through
without matching. Further investigation reveals that at the point
$1 is assigned to $content, it is still set to the result of
a *previous* match from further up in my program! This is why
both assertions fail to find what they're looking for, of course.
However, the Camel book (3rd ed) demonstrates (on page 213)
that code blocks *can* access backreferences from earlier in
the current match. So, what am I doing wrong?
I'm starting to worry that this may be a bug in my particular
copy of perl. I'm running the RISC OS port which reports as:
This is perl, version 5.005_03 built for arm-riscos
Copyright 1987-1999, Larry Wall
RISC OS port by Andrew Black and Nicholas Clark (1998),
Steve Ellacott (1996), Luke Taylor (1995) and Paul Moore (1990).
Release 1.13
Unfortunately, there isn't a more up to date version available
for RISC OS (at least not one that works fully) so I'm stuck.
Can anyone help?
Thanks.
--
James Taylor, London, UK PGP key: 3FBE1BF9
To protect against spam, the address in the "From:" header is not valid.
In any case, you should reply to the group so that everyone can benefit.
If you must send me a private email, use james at oakseed demon co uk.
------------------------------
Date: Wed, 20 Jul 2005 19:08:04 GMT
From: Stefan H. <stfhostf@kartos.de>
Subject: Re: Tk: Text works with TIE, Scrolled doesn't
Message-Id: <158td15g27r0ciofut7h54k8rj9en97n98@4ax.com>
On Thu, 14 Jul 2005 22:13:24 +0000 (UTC), lusol
<lusol@iMac-C.CC.lehigh.EDU> wrote:
>The trick is to use the Subwidget() method to fetch the Tk::Text
>widget reference and tie() to that:
>
>my $frog = $text->Subwidget( 'scrolled' );
>tie *STDOUT, ref $frog, $text;
thanks Steve for the lesson. I'm a little bit frustrated because I don't
know what I'm doing but it works :-)
I have experience on Perl but I never saw things like tie, * and ref.
Thanks again,
Stefan
------------------------------
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 8264
***************************************