Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Re: Progressive pattern matching

by blakem (Monsignor)
on Oct 18, 2001 at 02:40 UTC ( [id://119581]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Progressive pattern matching
in thread Progressive pattern matching

It took me longer than I thought to get this working last night... I therefore had to cut the actual golfing part short. Here is an updated version after spending a few minutes trimming chars.
#!/usr/bin/perl -w use strict; my $s = "APKLGIYSPRIGLYHFHKLDTPRLGAKLJHHDGFYSDA"; my @m = ( "ST", "P", "RK", "ILVF", "G", "ILVFM", "Y" ); @"=@'=@m;my%m;while($"=!$:--&&\@"||pop@"&&\@"||shift@'&&\@'){length($_ +)>2&& $s=~$_&&$m{$_}++for(glob'{'.join('',map{'{'.(join',',split(//)).'}'}@{ +$"}). '}')}for(sort{length($b)-length($a)}keys%m){print"$_ at ",index($s,$_) ++1,$/} =OUTPUT SPRIGLY at 8 PRIGLY at 9 PKLGIY at 2 SPRIGL at 8 KLGIY at 3 RIGLY at 10 SPRIG at 8 TPRLG at 21 TPRL at 21 IGLY at 11 LGIY at 4 SPRI at 8 GFY at 33 GIY at 5 TPR at 21 GLY at 12 SPR at 8
Basically, we loop through a set of munged @motif arrays transforming them into glob strings which happen to spit out the various substrings we're looking for.

-Blake

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://119581]
help
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