Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

In Perl 6 that's just...

by TheDamian (Priest)
on May 10, 2004 at 20:29 UTC ( #352203=note: print w/ replies, xml ) Need Help??


in reply to look for substrings and getting their location

$seq ~~ m:overlap/ GUAUG /; say "Found ", +@$0, " at:"; say "\t", $_.pos for @$0;

So in Perl 5.8 and above you could write:

use Perl6::Rules; use Perl6::Say; $seq =~ m:overlap/ GUAUG /; say "Found ", scalar(@$0), " at:"; say "\t", $_->pos for @$0;

And, as the modifier suggests, it correctly handles overlaps in the data.


Comment on In Perl 6 that's just...
Select or Download Code
Re: In Perl 6 that's just...
by Juerd (Abbot) on May 10, 2004 at 20:38 UTC

    say "\t", $_.pos for @$0;

    Can $_.pos here be written as .pos?

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      It can. I used the longer form because I was trying to keep the Perl 5 version as similar as possible to the Perl 6 version.

      Damian

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2014-09-17 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (98 votes), past polls