In adding a TO_JSON method (to convert a blessed reference via JSON.pm) into CGI::Cookie if I do this:
package CGI::Cookie;
sub TO_JSON {
return {
map { name => $_->name,
value => $_->value,
domain => $_->domain,
path => $_->path,
expires => $_->expires }
shift
}
}
syntax error at XXX.pm line 76, near "shift " syntax error at XXX.pm line 77, near "}" Compilation failed in require at (eval 50) line 3.
But if I do this:
package CGI::Cookie;
sub TO_JSON {
return {
map { ''.'name' => $_->name,
value => $_->value,
domain => $_->domain,
path => $_->path,
expires => $_->expires }
shift
}
}
it works
Can't for the life of me figure out why. Also just quoting "name" doesn't help. I have to concatenate an empty string for it to work.
I'm mystified.