Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: 'grouping' substrings?

by japhy (Canon)
on Feb 01, 2006 at 15:59 UTC ( [id://527085]=note: print w/replies, xml ) Need Help??


in reply to 'grouping' substrings?

I'd make use of Perl's @- and @+ arrays produces by regexes:
my $seq = "..."; my @groups; push @groups, [$-[0], $+[0]] while $seq =~ /M+/g; print "$_->[0] to $_->[1]\n" for @groups;
This gives me different values than you've shown, but I believe it's correct.

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: 'grouping' substrings?
by Anonymous Monk on Feb 01, 2006 at 16:15 UTC
    Yes, don't mind what I wrote, it was just an example... will try your code ASAP. Will also check index function.. thanx to both of you!
      Sorry to bother you again, but it doesn't seem to work. For example, the first group gives 5-16, while it should be 5-15, the second 32-45, while it should be 32-44 from what I can calculate... Are my maths poor??? Also, I can't understand what [$-[0], $+[0]] mean... Any tips ? Sorry, I'm just beggining Perl...
        I hope this isn't too obvious, but how about subtracting one from $+[0]?

        Updated per ikegami's reply - duh! I have a bad track record lately...

        [ ... ] means "Construct an array with '...' as content, and return a reference to it." This is documented in perlref.

        $-[0] and $+[0] are elements of the special arrays @- and @+. Refer to perlvar for more information.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-04-23 19:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found