in reply to How to get two array in subroutine
If you want to walk on the wild side, you can use the (very) old-fashioned typeglob arguments for passing something like a reference that is yet not (quite) a reference... technically... I guess... See Typeglobs and Filehandles in perldata.
>perl -wMstrict -le "use Data::Dumper; ;; our @a = (1, 2, 3, 4); our @b = (9, 8, 7, 6); f(*a, *b); ;; sub f { local (*c, *d) = @_; print Dumper \*c; print Dumper \*d; print @::c; print @::d; } " $VAR1 = \*::a; $VAR1 = \*::b; 1234 9876
(OTOH, the prototype answer given by CountZero is probably what your interviewer/teacher is looking for.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get two array in subroutine
by CountZero (Bishop) on Feb 10, 2011 at 06:30 UTC |