baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
well here is the problem, i want to make the below code work. the idea is that i want to pass some argument into sub which then does what it does and passes the result in the array that is every time the foreach func starts canceled to no arguments. i could do it without strict pragma but the strict pragma has to stay. example:
this example doesn't work because of @big (it should be: my @big). i tried to make it our @big but the logic is not on my side.use strict; %hash -> here i have some hash my @array = qw(...); my $a = 1; foreach my $r (@array){ walk($r); @big;<----------------------------------- foreach my $b (@big){ | $a++; | print " I am $b that loves $a\n"; | } | } | | | sub walk { | | my $i = shift; | push @big, $i;------------------------------- for (@{$hash{$i}}){ walk($_) }
thnx
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: subroutine recursion question
by Corion (Patriarch) on Jun 20, 2008 at 08:21 UTC | |
Re: subroutine recursion question
by ikegami (Patriarch) on Jun 20, 2008 at 08:24 UTC | |
Re: subroutine recursion question
by pc88mxer (Vicar) on Jun 20, 2008 at 08:23 UTC | |
by ikegami (Patriarch) on Jun 20, 2008 at 08:26 UTC | |
by pc88mxer (Vicar) on Jun 20, 2008 at 08:32 UTC | |
Re: subroutine recursion question
by moritz (Cardinal) on Jun 20, 2008 at 09:00 UTC |