RenalPete has asked for the wisdom of the Perl Monks concerning the following question:
output:use strict; sub bar{ if (1){ return do { #do block will return 1 if (1){ 1; } 1; } ; } } sub foo{ if (1){ return do { #do block will return 1 1; } ; } } print ( "foo said '".foo()."'\n"); print ( "bar said '".bar()."'\n");
This is all on debian - I get the same behaviour in stable (5.8.8-7) and unstable (5.8.8-11.1) - am I doing something wrong, or is this a bug? Thanks!localhost:~# perl /tmp/z.pl foo said '1' bar said '' localhost:~# perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. localhost:~#
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by kyle (Abbot) on Nov 02, 2007 at 17:13 UTC | |
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by gamache (Friar) on Nov 02, 2007 at 17:48 UTC | |
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by samtregar (Abbot) on Nov 02, 2007 at 17:06 UTC | |
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by moritz (Cardinal) on Nov 02, 2007 at 17:20 UTC | |
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by Prof Vince (Friar) on Nov 02, 2007 at 22:48 UTC | |
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by RenalPete (Acolyte) on Nov 02, 2007 at 18:48 UTC | |
|
Re: Strange behaviour when returning the value of "do {}" - possible perl bug?
by ambrus (Abbot) on Nov 03, 2007 at 16:57 UTC |