Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Re: Patter Finding

by demerphq (Chancellor)
on Sep 11, 2001 at 16:57 UTC ( #111735=note: print w/replies, xml ) Need Help??

in reply to Re: Patter Finding
in thread Pattern Finding

Hi Lemming,

Im a little confused. As posted your code goes into an infinte loop. When I s/$file/\$string/g I get the output as you said we would (impressive) However if minlen is 0 it goes into an infinite loop!

Also when I try the string:'hellohiothellobrakerakerashash' I only get one of the many words contained, and a couple that arent words.

2 : (hello) 2 : (aker) 2 : (ash)
I would expect any of the following:
hello,hi,othello,brake,rake,raker,rash,ash,hash,ohio, the,lob,bra,hell,era # I get this using substr counts: ak,ake,aker,akera,as,ash,el,ell,ello,er,era, he,hel,hell,hello,ke,ker,kera,ll,llo,lo, ra,rak,rake,raker,rakera,sh
So my guess is that the above results are coincidental or am I missing something? Yves

You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Replies are listed 'Best First'.
Re: Re: Re: Pattern Finding
by runrig (Abbot) on Sep 11, 2001 at 20:14 UTC
    I would expect any of the following: hello,hi,othello,brake,rake,raker,rash,ash,hash,ohio, the,lob,bra,hell,era

    I don't see how you could expect some of those strings, because some only appear once in the string (e.g. "othello", "ohio"), so you really couldn't call them a "pattern" unless you're matching against a dictionary file.

    My solution near the top of this thread sort of assumes that the string is a contiguous series of patterns (one of the original constraints was "String contains nothing but patterns"), so it only finds "hello" from your test string, but if you change this line:

    # From this if (/\G(.{2,})(?=.*?\1)/g) { # To this if (/\G.*?(.{2,})(?=.*?\1)/g) {
    Then it does better and finds "ash", "rake", and "hello" from your test string, which is about as good as it gets, I believe.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://111735]
[Lady_Aleena]: paco is a little over 2 years before my time.
[Discipulus]: you can try tachyon's iterative approach Re: Win32 Recursive Directory Listing
[Lady_Aleena]: I'm on Linux/
[beech]: isn't 2 year about standard recovery time for that kind of surgery?
[Discipulus]: if you hate FIle::Find
[Lady_Aleena]: I don't hate it, it just drives me crazy.
[Discipulus]: LA the solution is portable to whatever
[Lady_Aleena]: File::Find doesn't have a simple sub wanted example, like get the name of the file.
[Discipulus]: there is also find2perl with your perl installation

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2017-04-23 20:46 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (432 votes). Check out past polls.