In <12839.969393548@chthon>, Tom Christiansen writes:
:What can be done to make $ work "better", so we don't have to
:make people use /foo\z/ to mean /foo$/?  They'll keep writing
:the $ for things that probably oughtn't abide optional newlines.
:
:Remember that /$/ really means /(?=\n?\z)/. And likewise with \Z.

It might be reasonable to redefine $ to mean the same as \z whenever
the /s flag is supplied. Another possibility would be to have a
scoped "use re qw/simple_anchor/' pragma to achieve the same. And
another would be simply to switch the meaning of $ and \z.

None of these feel particularly satisfactory, however, and I think
any change to the current semantics would be difficult for existing
perl programmers.

Perhaps '$$' to mean 'match at end of string (without /m) or at end
of any line (with /m)? The p52p6 translator can easily replace
references to $$ with ${$}. I can't think of a usefully different
meaning for ^^, but as currently defined it will already do the
right thing.

I don't know what proposals have come out of the other wgs, but if
we know when a variable has been read from a line-oriented input
medium, then we could turn on the special meaning of $ only in such
cases and define it as $$ above in all other cases. I think this
would be more confusing, though.

We could also consider changing the base definition to (?=($/)?\z),
particularly if $/ is to be seen as a regexp.

I think I like $$ the best.

Hugo

Reply via email to