Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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...
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) {
not sure what to do at this point??

Any help is greatly appreciated,

New'b'ish

dr_jgbn

In reply to Progressive pattern matching by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found