> On Fri, 29 Sep 2000 01:02:40 +0100, Hugo wrote:
>
> >It also isn't clear what parts of the expression are interpolated at
> >compile time; what should the following leave in %foo?
> >
> >  %foo = ();
> >  $bar = "one";
> >  "twothree" =~ / (?$bar=two) (?$foo{$bar}=three) /x;
>
> It's not just that. You act as if this is assignment takes place
> whenever a submatch succeeds. So:
>
>  "twofour" =~ /(?$bar=two)($foo=three)/;
>
> Will $bar be set to "two", and $foo undef? I think not. Assignment
> should be postponed to till the very end, when the match finally
> succeeds, as a whole.

In general all assignments should wait to the very end, and then assign
them all.  However before code callouts (?{...}) and enemies, the named
assignments that are currently defined should be made (localised) so that
the code can refer to them by name.  If the expression finally fails the
localised values would unroll.

>
> Therefore, I think that allowing just any l-value on the left of the "="
> sign, is not practical. Or is it?

I think any simple scalar value is reasonable.

>
> OTOH I would rather have that all submatches would be assigned to a
> hash, not to global or lexical variables. I have no clue about what
> syntax that would need.

That is in RFC 150, I think there is a case for both.

Richard


Reply via email to