Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: suffix arrays

by BrowserUk (Pope)
on Jul 18, 2003 at 21:17 UTC ( #275755=note: print w/ replies, xml ) Need Help??


in reply to Re: suffix arrays
in thread suffix arrays

Unfortunately, as of 5.8.0, that still doesn't work properly.

perl> print join "\n", map{ \substr 'The quick brown fox', $_ } 0 .. +19 LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4) LVALUE(0x15d7cf4)

As you can see, each time you take an Lvalue from substr, it re-uses the same address. So you end up with and array of pointers to the last char in the string.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Comment on Re: Re: suffix arrays
Download Code
Re: Re: Re: suffix arrays
by Zaxo (Archbishop) on Jul 18, 2003 at 21:53 UTC

    Hmmm... In 5.8.1-RC2,

    perl -e'my $foo = "A string"; my @foo = map{\substr $foo, $_} 0..7; pr +int map {$$_,$/} @foo;' A string string string tring ring ing ng g $
    5.8.1 does more of what I mean!

    After Compline,
    Zaxo

      Ah! I only just got my 5.8.1 to build, so I haven't had chance to try it out there yet. Someone did mention that the p5p guys were working on a fix when this came up before, but that was way back before 5.8 was released and it was one of the first things I checked for in 5.8 but was disappointed. Once I've convinced myself that my build of 5.8.1 is reasonably safe to use, that will allow me to finish off a module that was almost ready for release 6 months ago.

      It appears the fix just made it into the wild. Thanks, its nice to know, and my apologies for casting aspersions.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-12-20 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls