http://www.perlmonks.org?node_id=1016413


in reply to Re^3: Single Quotes - how to avoid any escape processing?
in thread Single Quotes - how to avoid any escape processing?

> empty string?

I don't think that would create a problem, since the search for the end delimiter would begin right after the start delimiter, not including it.
The regex for matching such a single-quoted string would effectively be:
  /'(?:''|[^'])*'/
...which would match the empty string case just fine.

> What's easy for you might be the horror for someone else.

Well, one way to compare & contrast DWIM "horrors" would be to consider the likelihood of unsuspecting users "falling into the trap" while just going about their normal routine programming.

Many who learn Perl come to colloquially know single-quoted strings as "like normal strings, but without escaping and interpolating". Then they go about using them, with perfect results, until at some point they are bitten by weird bugs like the OP described.
While writing something like
  $path = '\\aaa\bbb';
a non-experienced user who knows single-quoted strings as "strings without escaping", won't even consider that the double-slashes might cause unintended behavior.

One the other hand, the same user would probably not write something like
  $contraction = 'Don''t';
unless they were consciously experimenting how single-quoted strings behave in special cases. It would raise a red flag, because it challenges what they know about how start and end delimiters for string literals work.

In both cases, people will not know how exactly things work until they are taught.
But in the second case, they will know about not knowing something when it matters, whereas in the first case it will catch them by surprise later in the form of bugs.