Sachin_dada has asked for the wisdom of the Perl Monks concerning the following question:
Hi All, I have a doubt in my code. I'm using subroutine, where once i call it, i'm storing those values another array variable & read each using Foreach loop. But i'm getting only the first value of the array, by using forreach loop. Could some please correct by code.
#!/usr/bin/perl -w use strict; sub job { @row= {AAA,BBB}; return @row; } my @red =job(); foreach my $r(@red) { print $r; }
Could someone please correct where i'm conceptually wrong. Its just returning 'AAA' as output, instead of returning both.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Subroutine - Return Array
by davido (Cardinal) on Nov 11, 2010 at 06:01 UTC | |
by JavaFan (Canon) on Nov 11, 2010 at 11:35 UTC | |
|
Re: Subroutine - Return Array
by suhailck (Friar) on Nov 11, 2010 at 05:45 UTC | |
|
Re: Subroutine - Return Array
by PeterPeiGuo (Hermit) on Nov 11, 2010 at 06:07 UTC |