On Wed, Sep 23, 2009 at 08:08:47PM -0400, Chas. Owens wrote: > On Wed, Sep 23, 2009 at 19:16, Mike McClain <mike.j...@nethere.com> wrote: > > On Tue, Sep 22, 2009 at 05:09:26AM -0400, Shawn H Corey wrote: > >> Roman Makurin wrote: > > Does anyone know of a case where one of these expressions would fail? <snip> > > Both the a and g cases only work because the assignment provides > scalar context. Failure to recognize this may cause you to write > <snip> > > which results in either an error (if farr returns an even number), or > worse, a very odd hash: > <snip> > > The solution is to force scalar context with scalar: > <snip> > > Of course, the best solution is to make farr context aware with the > poorly named [wantarray][1]: > <snip> > > sub farr { > my @a = qw/k l m/; > return wantarray ? @a : scalar @a; > } > <snip> > > [1] : http://perldoc.perl.org/functions/wantarray.html > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read.
Thanks Chas. You make a really great teacher. Mike -- Satisfied user of Linux since 1997. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/