jynx has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my @one = qw( one two three ); my $two = sub { print "we were passed @_\n" }; # here's the problem line: $two->( map { anda => $_ } @one ); # But this would work fine: #$two->( map { 1 && anda => $_ } @one );
i would think one would be able to code as i have above, but (on a Solaris 9 machine running the standard Perl 5.6.1 Sun install) apparently not. If i add parentheses i find out that apparently Perl is viewing { anda => $_ } as a hash reference, but map is expecting a code reference, so that's probably where the discrepency comes from.
Questions:
jynx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (5.6.1) map mayhem? (+{ {;)
by tye (Sage) on Oct 07, 2003 at 20:02 UTC | |
by bart (Canon) on Oct 07, 2003 at 21:26 UTC | |
by merlyn (Sage) on Oct 07, 2003 at 21:42 UTC | |
by Abigail-II (Bishop) on Oct 08, 2003 at 11:24 UTC | |
by diotalevi (Canon) on Oct 08, 2003 at 01:03 UTC | |
|
Re: (5.6.1) map mayhem?
by jasonk (Parson) on Oct 07, 2003 at 19:54 UTC | |
|
Re: (5.6.1) map mayhem?
by eric256 (Parson) on Oct 08, 2003 at 15:40 UTC |