[NTLUG:Discuss] Perl help

Rick Renshaw bofh69 at yahoo.com
Thu Feb 7 18:29:16 CST 2008


--- Stuart Johnston <saj at thecommune.net> wrote:

> In this case you would want a 'return'.  I changed your sub calls around 
> a little too.  If you were not in a sub, you would want to use 'next'.
> 
> 
> sub nextcut {
>      my $path = '/path/to/files/';
>      for $n (31000 .. 31500) {
>          if (! -e "$path/$n.wav" ) {
>                print "$n.wav\n";
>                return $n;
>          }
>      }
> }

Next wouldn't do anything useful in a loop at the end like the return is in the above sub.  Next
just skips the rest of the loop and starts the next iteration.  I think you meant last, which ends
the loop.


      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 




More information about the Discuss mailing list