develooper Front page | perl.perl5.porters | Postings from February 2013

[perl #116773] Documentation of $ in perlre

Thread Next
James E Keenan via RT
February 16, 2013 23:48
[perl #116773] Documentation of $ in perlre
Message ID:
On Fri Feb 15 05:45:39 2013, wrote:
> This is a bug report for perl from,
> generated with the help of perlbug 1.39 running under perl 5.16.2.
> -----------------------------------------------------------------
> I have been working with a regular expression that uses `$` with the
> `/m` modifier, and have relaised that I was misunderstanding how `$`
> works. The problem is the line
>      $        Match the end of the line (or before newline at the end)
> The way I read that is that `$` matches both before and after a
> newline, 

While I can see that there might be some fuzziness about the concept of
'line', I honestly can't see where you came by the idea that '$' would
match *after* a newline.

> whereas what this actually means is
>     Match the end of the _string_ (or before a newline at the end of
> the
> _string_)
> This makes no difference without the `/m` modifier, but with it I was
> expecting `$` to match twice for each line. After all that is what the
> documentation says!
> A _line_ is something very specific, and it is fair to think of it as
> a thing that is terminated by a newline character. Because regular
> expressions allow for multi-line strings I feel this should be
> changed.

Could you provide some examples of lines (strings?) where you
experienced this confusion?

Thank you very much.
Jim Keenan

via perlbug:  queue: perl5 status: new

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About