Dave Cross dave at
Wed May 1 16:58:54 BST 2013

Quoting Mark Fowler <mark at>:

> Dave wrote:
>> Otherwise new() returns false and the original string is used instead.
> Technically what Perl interpreted the original string to be is used instead.
> i.e. you wrote:
> return __PACKAGE__->new($_[0]) || $_[1]
> Not
>  return __PACKAGE__->new($_[0]) || $_[0]
> Which is where some of the confusion is coming from, since you  
> forgot to comment or explain what the heck $_[1] is ;-)

But the overload documentation already has that covered admirably.

   The corresponding values are references to functions which take three
   arguments: the first one is the initial string form of the constant, the
   second one is how Perl interprets this constant, the third one is how the
   constant is used. Note that the initial string form does not contain string
   delimiters, and has backslashes in backslash-delimiter combinations stripped
   (thus the value of delimiter is not relevant for processing of this string).
   The return value of this function is how this constant is going to be
   interpreted by Perl. The third argument is undefined unless for overloaded
   q- and qr- constants, it is q in single-quote context (comes from strings,
   regular expressions, and single-quote HERE documents), it is tr for  
   of tr/y operators, it is s for right-hand side of s-operator, and it is qq


More information about the mailing list