Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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.

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]
[Corion]: Oh yay. Why do I test a migration with transaction code "T" when the real trades from the migration will come with P9N (which is excluded from the processing)?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2017-09-26 15:07 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (296 votes). Check out past polls.