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

This is a newbie question, but what is the special variable, @-? For example, this code:

sub rightmost{ my($string, @patterns) = @_; my $rightmost = -1; while( my($i, $pattern ) each @patterns ) { $position = $string =~ m/$pattern/ ? $-[0] : -1; $rightmost = $position if $position > $rightmost; }

Replies are listed 'Best First'.
Re: Special Variables
by hippo (Archbishop) on Mar 13, 2014 at 16:54 UTC

    @- is a synonym for @LAST_MATCH_START as detailed in perlvar.

Re: Special Variables
by toolic (Bishop) on Mar 13, 2014 at 17:04 UTC
    Also from the command line:
    perldoc -v @-