[26560] in Perl-Users-Digest
Perl-Users Digest, Issue: 8699 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 23 09:05:38 2005
Date: Wed, 23 Nov 2005 06:05:06 -0800 (PST)
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, 23 Nov 2005 Volume: 10 Number: 8699
Today's topics:
a perl primedb project. <1e0n@163.com>
Re: Apparent bug in 5.8 wrt tied scalars <nospam-abuse@ilyaz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Nov 2005 21:26:04 +0800
From: 1e0n <1e0n@163.com>
Subject: a perl primedb project.
Message-Id: <dm1r05$n7c$2@news.cn99.com>
that's a perl primedb project i make:
https://sourceforge.net/projects/primedb
primedb is a project that attempt to generation prime numbers fast and
saving them to a database(Mysql or else) for prime research: finding
large number of prime,prime factorization,Goldbach's conjecture,twin
prime conjecture...
------------------------------
Date: Wed, 23 Nov 2005 07:40:12 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Apparent bug in 5.8 wrt tied scalars
Message-Id: <dm16cs$1s20$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Eric J. Roode
<sdn.girths00869@zoemail.net>], who wrote in article <Xns9713542B3A43Bsdn.comcast@216.196.97.136>:
> Here is a short program that illustrates bug #1:
>
> sub foo::TIESCALAR { bless {value => $_[1]}, $_[0] }
> sub foo::FETCH { $_[0]->{value} }
> tie my $test, 'foo', 'test';
> print "$test$test\n";
> This prints "testp\cX\c@" or other similar garbage. The first
> interpolation prints fine; the second is reminiscent of a
> non-NUL-terminated C string.
I think this is "as expected" (the state of "tieing" engine is pretty
pitiful....). There is a slot in a tied scalar where the value "is
created" each time the scalar is accessed; you use this slot two times
in the same expression. Essentially, you are trying to evaluate
$test . $test
The operator `.' expects to get two values; however, when $test is
calculated the second time, the first value "is overwritten", so you
get garbage. (This does not explain why the garbage is in the second
position, but you got the idea...)
> print "$test $test\n";
> there is no buggy behavior.
($test . ' ') . $test
Each `.' operator works on one copy only.
> Here is a short program that illustrates bug #2:
> use warnings;
> sub foo::TIESCALAR { bless {}, shift }
> sub foo::FETCH { return 2 }
> tie my $test, 'foo';
> my $bits = 3 & ~$test;
>
> This gives the warning
> Use of uninitialized value in 1's complement (~) at....
Maybe similar: ~ accesses its argument several times - once to
understand whether it is a string or number, then to fetch
string/number. (Well, I'm stressing my imagination....)
> Finally, the mysterious Bug #3:
>
> sub foo::TIESCALAR { bless {value => $_[1]}, $_[0] }
> sub foo::FETCH { $_[0]->{value} }
> tie my $VAR, 'foo', 'SEARCH';
> foreach my $var ($VAR)
> {
> print +($var eq $VAR) ? 'yes' : 'no';
> }
>
> This prints "no".
Likewise.
> Amusingly, change the "print" line to:
>
> print +(lc $var eq lc $VAR) ? 'yes' : 'no';
>
> and it prints "yes".
See above.
To work around, instead of "$test$test" you can use "$test$EMPTY$test"
etc.
Hope this helps,
Ilya
------------------------------
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 8699
***************************************