Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Special Variables and Multiple Regexp Matching

by LanX (Bishop)
on Nov 18, 2013 at 00:30 UTC ( #1063023=note: print w/replies, xml ) Need Help??

in reply to Special Variables and Multiple Regexp Matching

I'm not sure what your goal is...

We have to guess how '$token' and '$line' look like, and I have no idea why the (undemonstrated) while loop should not terminate.

(see How (Not) To Ask A Question and How do I post a question effectively?)

But pos will tell you where the last match paused, the rest should be easily calculated with 'length($token)' (IF token is just a simple string)

DB<127> $str= "a b " x 4 => "a b a b a b a b " DB<128> $token="a" => "a" DB<129> print pos($str),": $1\n" while $str =~ /($token)/g 1: a 7: a 13: a 19: a


) well except the fact that lc always creates a new string which resets the search-position. Simply lowercase once '$line' before you loop!

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1063023]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-06-23 10:56 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.