rovf has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
could someone kindly explain to me, why this innocent little program is syntactically wrong?
ActiveState Perl complains:use strict; use warnings; my $xnix='X'; sub f { {$xnix => 100}->{'X'} } print f(),"\n";
The problem must be related to the usage in a sub, because the similarsyntax error at U:\develsv\ARTS\playground\hash_problem.pl line 7, nea +r "}->" syntax error at U:\develsv\ARTS\playground\hash_problem.pl line 8, nea +r "}"
works as expected.use strict; use warnings; my $xnix='X'; my $f={$xnix => 100}->{'X'}; print $f,"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't see the syntax error here...
by moritz (Cardinal) on Jun 13, 2008 at 11:54 UTC | |
by rovf (Priest) on Jun 16, 2008 at 08:04 UTC | |
|
Re: Can't see the syntax error here...
by andreas1234567 (Vicar) on Jun 13, 2008 at 12:00 UTC |