in reply to How to get two array in subroutine
If you would try prototypes (and you really do not want to do that unless you know pretty well what you are doing) you can try this:
Output:use Modern::Perl; sub no_ref(\@\@) { my ($first, $second) = @_; say "First: @$first"; say "Second: @$second"; } my @alfa = (1 .. 10); my @beta = ('a' .. 'j'); no_ref @alfa, @beta;
It still uses references, but they are kind of hidden. And you cannot call the subroutine with &no_ref!First: 1 2 3 4 5 6 7 8 9 10 Second: a b c d e f g h i j
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get two array in subroutine
by arivu198314 (Sexton) on Feb 09, 2011 at 13:39 UTC | |
by CountZero (Bishop) on Feb 09, 2011 at 13:52 UTC | |
by Anonymous Monk on Feb 09, 2011 at 13:53 UTC |