Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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
Replies are listed 'Best First'.
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 => '', plp_site => '', 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.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2016-05-24 19:20 GMT
Find Nodes?
    Voting Booth?