http://qs321.pair.com?node_id=255801


in reply to Re: •Re:^2 •Re: Checking for single digit
in thread Checking for single digit

I checked because I can never remember the difference myself. From the camel, 3rd ed., page 179:

The \A assertion matches only at the beginning of the string, no matter what. However, the ^ assertion is the traditional beginning-of-line assertion as well as a beginning-of-string assertion. Therefore, if the pattern uses the /m modifier and the string has embedded newlines, ^ also matches anywhere inside the string immediately following a newline character.

So, without the /m modifier, ^ and \A are identical.

For completeness (same page):

The \z metasymbol matches at the end of the string, no matter what's inside. \Z matches right before the newline at the end of the string if there is a newline, or at the end if there isn't. The $ metacharacter usually means the same as \Z. However, if the /m modifier was specified and the string has embedded newlines, then $ can also match anywhere inside the string right in front of a newline.
90% of every Perl application is already written.
dragonchild
  • Comment on Re: Re: •Re:^2 •Re: Checking for single digit