A trip down memory lane ...
I reached across my desk and grabbed my original (pink) version of the Camel book. After blowing off a decade or two's worth of dust, I had a look around.
[Note: The printing history shows Jan. 1991 as "First Edition", then Aug. 1991 and Mar. 1992 as "Minor corrections". It would be a fair assumption that I have the more recent of those; page numbers below may be out by one or two for those with other versions.]
In "Chapter 3 The Gory Details" (pp. 65-121); under the "Packages" section (pp.119-121); I found on page 120:
local(*foo) = *bar; local($_main{'foo'}) = $_main{'bar'};... the *foo is more efficient because it does the symbol table lookup once at compile time ...
Also of nostalgic interest was the use of $main'var instead of $main::var. I haven't used the former version in over 20 years; however, it's still valid:
$ cat pm_11137628_pkg_sep.pl use strict; use warnings; our $x = 42; print $], "\n"; print $main'x, "\n"; print $main::x, "\n";
$ perl pm_11137628_pkg_sep.pl 5.034000 42 42
"foo(*arr1,*arr2)"
Under the "Subroutines" section (pp. 99-102); on page 99; I note a small syntax change is required:
"A subroutine is called using the do operator or the & operator. The & operator is the preferred form."
However, other than that small syntax change, the gist of what you wrote is correct. There's an example on page 102:
sub arrayadd { local(*a, *b) = @_; ... } @foo = (1,2,3); @bar = (10,20,30); @totals = &arrayadd(*foo, *bar);
[Disclaimer: Everything I've quoted from the book needed to be entered by hand. I believe it's all correct but apologise in advance for any typos that may have crept in.]
The "trip down memory lane" concludes. I hope that was an interesting read. I do acknowledge that it was way off-topic with respect to the OP subject.
— Ken
In reply to Re^5: POD for use feature 'declared_refs' wrong
by kcott
in thread POD for use feature 'declared_refs' wrong
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |