On Apr 10, 2009, at 2:33 PM, Michael G Schwern wrote:

In debugging a new and fascinating MakeMaker/VMS problem, I discovered this gem:

$ perl -wle "print q[12 '3' 45]"
12 '3' 45
$ perl -wle "print q[12 '' 45]"
12

'' seems to mean something special, even inside double quotes!

What's going on and what's the work around?

Single quotes cause symbol expansion. Inside double quotes, that normally doesn't happen, but you can force it to by doubling the first single quote:

$ foo = "Bar"
$ write sys$output "''foo'"
Bar

And as you discovered, a doubled single quote inside double quotes evaluates to nothing if the next token is not a symbol.

The only thing I can think of at the moment if you really need the literal single quote is pasting together separate strings:

$ perl -wle "print q[12 '] . q[' 45]"
12 '' 45



For the curious, the issue is this:

        $(NOECHO) $(ABSPERLRUN) "-MExtUtils::Install" -e "pm_to_blib({...@argv},
'[.blib.lib.auto]', '$(PM_FILTER)', '$(PERM_DIR)')" "--" -

In this case maybe

'[.blib.lib.auto]', '$(PM_FILTER)', '$(PERM_DIR)'

could become

q{[.blib.lib.auto]}, q{$(PM_FILTER)}, q{$(PERM_DIR)}




when PM_FILTER is not set. The argument is completely lost and perl sees:

   pm_to_blib({...@argv}, '[.blib.lib.auto]', , '755')

to add to the fun, Perl will collapse multiple commas. So that's equivalent to:

   pm_to_blib({...@argv}, '[.blib.lib.auto]', '755')

and the PM_FILTER argument is lost to the void. :/


--
Defender of Lexical Encapsulation

________________________________________
Craig A. Berry
mailto:craigbe...@mac.com

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to