Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2019-11-20 19:38 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (100 votes). Check out past polls.