In <[EMAIL PROTECTED]>, Bart Lateur writes:
:On Fri, 29 Sep 2000 00:29:31 +0100, Hugo wrote:
:>:I originally had thought of providing a separate, dedicated regex 
:>:modifier, just for the match prefix, but I don't think too many people 
:>:need this that desperately. You can easily build a working application 
:>:with just the '/z' modifier. If you can't, you're in over your head, 
:>:anyway.  ;-)
:>
:>I don't understand this paragraph.
:
:I'll have to rework this into plain English.

Thanks, I understand it now. Since the functionality is provided for
by /z, I'd suggest replacing that paragraph with an example showing
how you can use it to detect a prefix match; I think that involves
rewriting your /p example something like:
  if (/^$pat$/z) {
    print "found a complete match";
  } elsif (defined pos) {
    print "found a prefix match";
  } else {
    print "not a match";
  }

:p.s. I often wondered why pos() is not just a special variable. That
:would make more sense, I think, from a user POV, than making it a
:special function.

I think because it is associated with a variable:

  ($a, $b) = qw/ banana baobab /;
  $a =~ /a/gc, $b =~ /b/gc;
  print pos($a), pos($b);
  pos($a)++, pos($b)++;
  print pos($a), pos($b);

Perhaps it would have been helpful if 'pos' and 'pos()' were
different, similar to eof: have pos() refer to $_, and bare pos
refer to the last match. This would particularly have helped when
the target of the match was not a variable ("test" =~ $re) or
when it was a complex or expensive value ($self->slowload->{attr}).
However, given the confusion this duality of eof has engendered
over the years it is probably just as well not to.

Hugo

Reply via email to