Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 examining the Monastery: (9)
As of 2015-07-07 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls