duh...  thanks tons!

On Mon, Nov 26, 2012 at 8:37 AM, Tobias Hoellrich <thoel...@adobe.com>wrote:

>  *From:* perl-win32-users-boun...@listserv.activestate.com [
> mailto:perl-win32-users-boun...@listserv.activestate.com<perl-win32-users-boun...@listserv.activestate.com>]
> *On Behalf Of *Greg Aiken
> *Sent:* Monday, November 26, 2012 9:19 AM
> *To:* Perl-Win32-Users@listserv.ActiveState.com
> *Subject:* 'mysplit' ???
>
> i just ran across a perl recursion example that i am trying to
> understand...
>
> (url =*
> http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html
> *<http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html>
> )
>
> sub mysplit
> {
>     my ($total, $num_elems, @accum) = @_;
>
>     if ($num_elems == 1)
>     {
>         push @accum, $total;
>         print join(",", @accum), "\n";
>
>         return;
>     }
>
>     for (my $item=0 ; $item <= $total ; $item++)
>     {
>         my @new_accum = (@accum, $item);
>         mysplit($total-$item, $num_elems-1, @new_accum);   #<<<<<<<<<<<<
> 'mysplit'
>     }
> }
> mysplit(10,3);
>
> the line of code ive never seen before, and am struggling with to
> understand - is the following...
>
>    mysplit($total-$item, $num_elems-1, @new_accum);
>
> ive 'googled' the word 'mysplit' and find no results.
>
> might anyone know exactly what 'mysplit' is?
>
>
> Hi Greg – this is an example about recursions in perl. “mysplit” is the
> name of the sub you’re currently in (look at the beginning where it says
> “sub mysplit”). The subroutine is calling itself.
>
> Hope this helps – Tobias
>
>
>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to