in reply to Re: map and each?
in thread map and each?
Big difference. Generally, double quoting scalars is a Bad Idea only if it is "useless". I see a lot of newbies trying silly things like:my $gah = join ("<br>", map {'$_ = $somehash{$_}'} keys %somehash);
Only the first set of double quotes are necessary for the special character "\n". So ,what harm is done with that example? None, but this behaviour usually stems from Cargo Cult Programming, and that's why it's a Bad Idea. Double quotes are good when used responsibly. Irresponsible use will lead to mistakes like thinking that an object ref is a scalar:my $first = "Hello World\n"; my $second = "$first"; print "$second";
use strict; use CGI; my $q = CGI->new(); print "$q->param('foo')\n"; # wrong print $q->param('foo'),"\n"; # right print $q->param('foo')."\n"; # right print "@{[$q->param('foo')]}\n" # right, but twisted ;)
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|