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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.