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

Answer: How do I retrieve the position of the first occurrence of a match?

by lima1 (Curate)
on Oct 04, 2007 at 16:01 UTC ( #642691=categorized answer: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    $line =~ m{(\d+)}g;
    my $pos = pos($line) - length $1;
  2. or download this
    $line =~ m{\d+};
    my $pos = length $`;
  3. or download this
    $line =~ m{\d+}g;
    my $pos = pos($line) - length $&;
  4. or download this
    $line =~ m{\d+};
    my $pos = $-[0];

Log In?

What's my password?
Create A New User
Tanktalus has to figure out why his cb talker isn't working :(
[choroba]: https?
[choroba]: That was at least why my cb talker wasn't working.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2018-07-15 21:20 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (326 votes). Check out past polls.