New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
map failing to parse with 2 element unparenthesis list in a block #14258
Comments
From miller.hall@gmail.comThis is a bug report for perl from miller.hall@gmail.com, The following will not compile use warnings; my $vex = [ { _dirty => "muddy waters" } ]; print map { "$_", $vex->[$_]{_dirty} } ( 0 .. $#$vex ); It will throw the error syntax error at map.pl line 8, near "} ( " To fix, simply put parenthesis around the list in the block. Alternatively, Flags: Site configuration information for perl 5.20.1: Configured by miller at Tue Sep 23 16:58:21 PDT 2014. Summary of my perl5 (revision 5 version 20 subversion 1) configuration: @INC for perl 5.20.1: Environment for perl 5.20.1: |
From @jkeenanOn Wed Nov 19 09:58:41 2014, miller.hall@gmail.com wrote:
This can be seen more clearly if we clear out some non-essentials: ##### $ perl -E 'say map { $_, 'alpha' } (0);' $ perl -E 'say map { ("$_", 'alpha') } (0);' I suspect that this is documented behavior (hence, not a bug), though I don't have the citation yet. Thank you very much.
-- |
The RT System itself - Status changed from 'new' to 'open' |
From @cpansproutOn Wed Nov 19 16:04:21 2014, jkeenan wrote:
perlfunc/map This same bug gets reported again, and again, and again. So, while it is documented, I’m going to consider it a documented bug. It is fixable for simple cases. -- Father Chrysostomos |
From @jkeenanOn Wed Nov 19 16:14:04 2014, sprout wrote:
Specifically: ##### %hash = map { "\L$_" => 1 } @array # perl guesses EXPR. wrong
-- |
From @demerphqOn 20 November 2014 01:23, James E Keenan via RT <perlbug-followup@perl.org>
It is fixable for all cases. Simply always write: map {; .... } @list; That leading semicolon is critical. IMO the advice to use a plus is broken. Yves -- |
From miller.hall@gmail.comIt was pointed out that is documented in perldoc for map. Would therefore delete this bug report, but don't know now :) Regards, On Wed, Nov 19, 2014 at 9:58 AM, <perlbug-followup@perl.org> wrote:
|
From @cpansproutOn Thu Nov 20 05:24:40 2014, demerphq wrote:
How is it broken? -- Father Chrysostomos |
From @demerphqOn 20 November 2014 14:58, Father Chrysostomos via RT <
The advice is broken because the heuristic involving plus breaks the $ perl -wle'my @things= map { +3, 1 }, 1..10; print @things' Also it is of poor value because it is not very general: $ perl -wle'my @things= map { no warnings; $_+1 } 1..10; print @things' Advising people to use semicolon works reliably, and does not involve a Yves |
From @ikegamiOn Thu, Nov 20, 2014 at 8:24 AM, demerphq <demerphq@gmail.com> wrote:
That's perverse! In the very rare case where you want to create a list of hash refs, map { +{ value => $_ } } LIST The rest of the time "map {" should always be "map BLOCK". The endless stream of questions and bug reports about this justifies the - Eric |
From @demerphqOn 20 November 2014 16:09, Eric Brine <ikegami@adaelis.com> wrote:
I don't agree. It is perfectly normal. And the only reliable way to force
If that ever becomes true then fine. But its not true now, and the advice
Personally I would like to see map EXPR, LIST go away entirely. Yves |
Migrated from rt.perl.org#123259 (status was 'open')
Searchable as RT123259$
The text was updated successfully, but these errors were encountered: