agynr has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, Is there any alternative for pos to find the position of the last search, as in my document it takes a lot of time on that particular statement. I am using Perl Builder as the editor and I have to wait a long for the position to calculate.

Replies are listed 'Best First'.
Re: Alternative of Pos
by Corion (Patriarch) on Jan 24, 2005 at 10:24 UTC

    You must be reading your timings wrong, as a call to pos($scalar) returns merely a value stored with $scalar, and thus is always quite fast. Most likely you are using a suboptimal regular expression to set pos, or your data is large and what you want to do just takes time.

    In all cases, without code, we can't help you.

      But in the spirit of give 'em what they ask for, the answer is $-[0] (see @- in perldoc perlvar).