Anything contained in double quotes is evaluated by the perl interpreter, while anything contained in single quotes is not.
This becomes very important for instance if you wish to include your email address in your script for use by the mail routine or to output in a dynamic html page.
The statement:
$owner = 'jaguar@iinet.net.au';
will correctly substitute my email address for $owner in any print statement.
The statement:
$owner = "jaguar@iinet.net.au";
will cause the script to crash. The reason for this is that the @ is a special character in perl, as is the $ and %. When perl encounters this statement it attempts to evaluate the array @iinet, which of course does not exist. It also has difficulty evaluating net and au, because these are preceded by the dot (.) or concatenation operator. Concatenation can only be performed on scalar variables, constants and strings.
Of course you could use the statement:
$owner = "jaguar\@iinet.net.au";
to achieve the desired result, but I'm a firm believer in "Don't backslash unless you need to".
Back to the Perl Tutorial
Back to Explain Backslash