in reply to Re^2: error message in the end of the array looping?
in thread error message in the end of the array looping?

If you try to return when not in a sub you get:

use strict; use warnings; return 10;

Prints:

Can't return outside a subroutine at noname2.pl line 4.

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^4: error message in the end of the array looping?
by dsheroh (Monsignor) on May 30, 2006 at 20:07 UTC
    That warning didn't look familiar so I poked around a little on google and it turns out that I misremembered it backwards... The actual warning I was thinking of was "Exiting subroutine via next", for which the solution is to exit from the sub using return instead of next... So return was the cure for my half-remembered warning rather than the cause.