Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am a seeker of perl wisdom...have worked on this for days too no avail.
I would like to take an input string e.g. "abcde" (more specifically it is like (a|b)(b|c)(c|d|e)) start at the first position "a" or (a|b) and search through another string of letters. If it finds "a", I would like the program to continue to "b" and then search with "ab". Again, if it finds the string "ab", next to try "abc" etc. until it can no longer extend the string and find a resulting match. i.e. it will find "abcd" then add onto it "e"...not find "abcde" and so print out just "abcd". I deperately hope this makes sense. Here is a snippet of my actual program to give you a basic idea of what I have done thus far...
Any help is greatly appreciated,
New'b'ish
dr_jgbn
I would like to take an input string e.g. "abcde" (more specifically it is like (a|b)(b|c)(c|d|e)) start at the first position "a" or (a|b) and search through another string of letters. If it finds "a", I would like the program to continue to "b" and then search with "ab". Again, if it finds the string "ab", next to try "abc" etc. until it can no longer extend the string and find a resulting match. i.e. it will find "abcd" then add onto it "e"...not find "abcde" and so print out just "abcd". I deperately hope this makes sense. Here is a snippet of my actual program to give you a basic idea of what I have done thus far...
not sure what to do at this point??print "Name of file containing various random strings?\n"; chomp ($motif=STDIN [omitting <>]); open (MOTIF, "$motif") || die "$!"; print "String to search with?\n"; chomp ($blocks=STDIN ); while (MOTIF) { @motif = MOTIF}; foreach (@motif) {
Any help is greatly appreciated,
New'b'ish
dr_jgbn
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Progressive pattern matching
by Masem (Monsignor) on Oct 14, 2001 at 05:41 UTC | |
by Anonymous Monk on Oct 14, 2001 at 08:26 UTC | |
by Corion (Patriarch) on Oct 14, 2001 at 12:12 UTC | |
by tfrayner (Curate) on Oct 15, 2001 at 19:35 UTC | |
by pike (Monk) on Oct 15, 2001 at 13:42 UTC | |
Re: Progressive pattern matching
by tommyw (Hermit) on Oct 14, 2001 at 04:59 UTC | |
Re: Progressive pattern matching
by chipmunk (Parson) on Oct 14, 2001 at 19:14 UTC | |
Re: Progressive pattern matching
by tfrayner (Curate) on Oct 17, 2001 at 14:11 UTC | |
by blakem (Monsignor) on Oct 17, 2001 at 15:33 UTC | |
by tfrayner (Curate) on Oct 17, 2001 at 17:25 UTC | |
by blakem (Monsignor) on Oct 18, 2001 at 02:40 UTC | |
Re: Progressive pattern matching
by tfrayner (Curate) on Oct 15, 2001 at 18:52 UTC | |
by Anonymous Monk on Oct 16, 2001 at 09:12 UTC |
Back to
Seekers of Perl Wisdom