2009/10/31 Aristotle Pagaltzis <pagaltzis@gmx.de>:
> * George Greer <perl@greerga.m-l.org> [2009-10-31 00:40]:
>> I suppose the answer could be "if you're subscripting a hash at the
>> end of an 'if' then you must include the parentheses" but that's a
>> little too circumstantial for my tastes and potentially surprising if
>> someone writes:
>>
>> sub return_baz_if_foobar { if $foo{bar} { "baz" } }
>>
>> and suddenly gets a "can't use string as a HASH ref" error.
>
> There are cases with very similar ambiguities that do not get
> resolved very intuitively:
>
> my @hashes = map { $_ => "blah_$_" }, qw( foo bar );
>
> And there is another case where I always write `map {; ... }`
> (note the semicolon) to force block interpretation, but I’m
> racking my brain and can’t come up with what it was.
>
Pramatta like `use warnings`:
map { no warnings; .... } @list
produces a syntax error.
map {; no warnings; .... } @list
does not.
This is an Abigail "fingerprint" by the way. If i found that map{}
usage combined with space between subscripts on sub calls or composite
structures I would bet money Abigail wrote the code. (And I would
probably win) :-)
cheers,
Yves
--
perl -Mre=debug -e "/just|another|perl|hacker/"
Thread Previous
|
Thread Next