[Edinburgh-pm] syntax error weirdness

David Baird lists.riverside at gmail.com
Fri Aug 5 01:59:50 PDT 2005


On 8/5/05, Jonathan Barber <jon at trinity.fluff.org> wrote:
> On Fri, Aug 05, 2005 at 12:58:01AM +0100, David Baird wrote:
> > dave at evesham$ perl -e 'map { $_,1 } "x"'
> > dave at evesham$ perl -e 'map { "$_" } "x"'
> > dave at evesham$ perl -e 'map { "$_",1 } "x"'
> > syntax error at -e line 1, near "} "x""
> > Execution of -e aborted due to compilation errors.
> > dave at evesham$ perl -v
> >
> > This is perl, v5.8.6 built for i386-freebsd-64int
> >
> > Anybody know why the third line shouldn't compile? Just seems weird.
> 
> I think it's down to perl trying to guess whether the curly braces are a
> block, expression or a hash ref. From the map fucntion's perldoc
> (perldoc -f map):

Thanks for the pointer, nice to start the day with a reduction in the
weirdness quotient.

d.


More information about the Edinburgh-pm mailing list