bradcan has asked for the wisdom of the Perl Monks concerning the following question:
# this works: my $default = '""'; # double quotes to be inserted when my $name = ''; # is empty my $insert = $empty || $default; # insert this print "name = $insert\n";
The result is either: `name = ""` or `name = fred`, when $name = 'fred'. So far so good.
But how do I get rid of the spurious variable $insert? I expected something like this:
print "name = ${\ $name || $default }\n"; # dosen't work!!
to work, but, results in `name =` missing the "". ie the code interpolation is null when $name = ''. Does || mean something different in a code interpolation?
Am I missing some subtlety? :-(
Thanks in advance.
|
|---|