Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Substr ref anomoly (revisited)

by tachyon (Chancellor)
on Jun 30, 2004 at 06:34 UTC ( [id://370691]=note: print w/replies, xml ) Need Help??


in reply to Substr ref anomoly (revisited)

AS 5.6.1 behaves in a different manner. Note how the ref is always the same.....

C:\>perl test.pl LVALUE(0x1aae9d0) : the LVALUE(0x1aae9d0) : quick LVALUE(0x1aae9d0) : brown LVALUE(0x1aae9d0) : fox LVALUE(0x1aae9d0) : jumps LVALUE(0x1aae9d0) : over LVALUE(0x1aae9d0) : the LVALUE(0x1aae9d0) : lazy LVALUE(0x1aae9d0) : dog --- LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog LVALUE(0x1aae9d0) : dog C:\>perl -v This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 635 provided by ActiveState Corp. http://www.ActiveState. +com Built 15:34:21 Feb 4 2003

cheers

tachyon

Replies are listed 'Best First'.
Re^2: Substr ref anomoly (revisited)
by tadamec (Beadle) on Jun 30, 2004 at 06:49 UTC

    I noticed that under 5.6.1 when doing some DBI work. It took me forever to realize that every element in the @data array was actually being set to the same address.

    while( my $row = $sth->fetchrow_hashref() ) { push @data, $row; }

    I thought it had something funky to do with the $row ref being outside of the while loop's curly-brace scope (is this a closure?). I solved the problem thusly:

    while( my $ref = $sth->fetchrow_hashref() ) { my $row = $ref; push @data, $row; }

    I never saw a problem with row ordering. And, from my logic, this really shouldn't work. It reads (to me) that I'm copying the $ref reference into the $row variable, instead of creating a new reference. But, for whatever reason, the array started working the way I figured it should.

    I had chalked this up as my not completely understanding the logic and scoping of references.

Re^2: Substr ref anomoly (revisited)
by BrowserUk (Patriarch) on Jun 30, 2004 at 06:44 UTC

    Good point. I forgot to mention that it wouldn't work at all before 5.8.3, but I thought the "one lvalue per substr" bug was fixed in 5.8.3. From davidos reponse it looks like it was nearly fixed in 5.8.3 and finally fixed in 5.8.4.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://370691]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found