in reply to Differences between " " and ' '?

If there's no variables inside to be interpolated, the optimizer transforms double quotes to single quotes:
#!/usr/bin/perl #testscript if($a eq "quackidiquack") { } if($a eq 'quackidiquack') { }
Now let's see what the optimizer does:
perl -MO=Deparse testscript if ($a eq 'quackidiquack') { (); } if ($a eq 'quackidiquack') { (); } testscript syntax OK

Replies are listed 'Best First'.
Re^2: Differences between " " and ' '?
by diotalevi (Canon) on Jul 31, 2005 at 05:06 UTC
    Your conclusion is correct but your methods are dodgy. B::Deparse doesn't tell you anything about how things are compiled or executed internally and it can be incorrect or just misleading. For accuracy, use B::Concise or something else that shows you the compiled optree. B::Deparse attempts to produce some sensible perl code based on the optree but it isn't really an oracle and it isn't always right.
    Added

    B::Deparse is supposed to produce canonically correct output as a core goal and it does really well. It just isn't so perfect. It also won't tell you that '...' is internally the same thing as "...". (it is)

Re^2: Differences between " " and ' '?
by Ace128 (Hermit) on Jul 31, 2005 at 04:59 UTC
    Hey, that "perl -MO=Deparse .. " is something new for me! Nice, and thanks! Good to know about... like in cases like this!