in reply to search one instance

m/^.*?(data)/

An example

perl -le '$_="abc"."data" x 5;print; print "position of first data : ",pos while m/^.*?(?=data)/g;' abcdatadatadatadatadata position of first data : 3

Replies are listed 'Best First'.
Re^2: search one instance
by raybies (Chaplain) on Nov 03, 2010 at 16:24 UTC
    when I tried your example, it reported the position of the last "data", not the first.
Re^2: search one instance
by AnomalousMonk (Archbishop) on Nov 03, 2010 at 19:22 UTC

    I, also, cannot figure out how you get a position of 3 from the given code.

      Sorry, i missed out a question mark "?" in m/^.*?(?=data)/

      Thanks for noticing that :)
      Updated the code above...