develooper Front page | perl.perl5.porters | Postings from February 2006

study and tied variables

Thread Next
From:
Nicholas Clark
Date:
February 22, 2006 03:57
Subject:
study and tied variables
Message ID:
20060222115703.GE616@plum.flirble.org
Currently C<study> will study anything. As I understand it, it's reading the
scalar's string, building a frequency table of characters in it, and then
using magic to arrange that if the variable is written to, the frequency
table is reset.

All well and good, but I have a suspicion that this is not going to work for
active variables (such as tied variables or anything with string
overloading) that could conceivably return a different string on each read,
*without* ever being written to.

However, I'm having trouble coming up with a test case that demonstrates
this. I suspect mainly because I don't really know what level of regexp
complexity takes advantage of the REXEC_SCREAM flag, and therefore how to
craft two strings to match against, one to study, the second to actually
match against, such that the REXEC_SCREAM uses the study data from the
first and produces the incorrect result.

Basically, I'm wondering if anyone can come up with a test where

    # $var is tied
    study $var;
    $var =~ /$pattern/;

fails, but taking out the study it passes, specifically because $var returned
two different strings.

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About