4.3. Regular Expressions

You may be accustomed to using s//A New Beginning/ to insert some text at the beginning of the current line in some applications. In Perl (as in sed), the empty regular expression doesn't match a zero-length substring; it matches whatever the previous regular expression matched. If there isn't a previous regular expression, Perl and sed part company: Perl treats it as matching the beginning of the string; sed says it's an error.

Get Perl Debugged now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.