Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^4: POD for use feature 'declared_refs' wrong

by LanX (Sage)
on Oct 19, 2021 at 09:43 UTC ( #11137715=note: print w/replies, xml ) Need Help??

in reply to Re^3: POD for use feature 'declared_refs' wrong
in thread POD for use feature 'declared_refs' wrong

I'm pretty sure one needed to pass a glob for multiple arrays, because references were missing


Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^5: POD for use feature 'declared_refs' wrong
by kcott (Bishop) on Oct 19, 2021 at 15:14 UTC

    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 use strict; use warnings; our $x = 42; print $], "\n"; print $main'x, "\n"; print $main::x, "\n";
    $ perl 5.034000 42 42

    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

        Didn::t know that. Thanks for letting us know.

        Though it puts a crimp on Perl joke modules, there don::t appear to be enough of those to warrant keeping it -- the only one I remembered without googling was Chris Nandor's classic Do'h, released before the CPAN Acme namespace was born.

        This is all I could find:

        • Do'h by Chris Nandor
        • D'oh::Year by Mick Schwern
        • Acme::Don't by Damian Conway
        • Test::More - this core module uses a typeglob alias (sub isnt { ... } *isn't = \&isnt) to allow you to write isn't in your tests instead of isnt ... hardly a critical feature. :)

        To be honest, I was surprised to find that it was still valid in v5.34 — thanks for the info.

        I had written, "I haven't used [it] in over 20 years"; upon reflection, I believe my last usage was probably in 1996 or 1997; so that's closer to a quarter of a century.

        The message, to which you linked, had "... $user's problem ...", followed by "This bites experts and new users alike ...". I suspect I could have been one of those bitten, if reviewing another's code without "use warnings;". In v5.28, a new warning was added: see "perl5280delta: New Warnings" and "perldiag: Old package separator used in string". My normal code would be something along these lines:

        ken@titan ~/tmp $ cat use strict; use warnings; my $user = 'ken'; print "... $user's problem ...\n";

        which, when run, gives me ample feedback:

        ken@titan ~/tmp $ perl -v This is perl 5, version 34, subversion 0 (v5.34.0) built for cygwin-th +read-multi ... ken@titan ~/tmp $ perl Old package separator used in string at pm_11137628_pkg_sep_in_string. +pl line 6. (Did you mean "$user\'s" instead?) Name "user::s" used only once: possible typo at pm_11137628_pkg_sep_in line 6. Use of uninitialized value $user::s in concatenation (.) or string at line 6. ... problem ...

        I don't have anything earlier than v5.30 on that system:

        $ perlbrew list * perl-5.34.0 perl-5.33.5 perl-5.32.0 perl-5.30.0

        However, on another OS:

        C:\Users\ken\tmp>perl -v This is perl 5, version 26, subversion 3 (v5.26.3) built for MSWin32-x +64-multi-thread ... C:\Users\ken\tmp>perl Name "user::s" used only once: possible typo at pm_11137628_pkg_sep_in line 6. Use of uninitialized value $user::s in concatenation (.) or string at line 6. ... problem ...

        Not quite as "ample" feedback. I expect I could work it out from here; others might be saying frustratedly: 'But there is no "user::s" in my code'.

        I read through about the first dozen NNTP messages. Most discussion seemed to be about whether removal should be partial or complete, and backward-compatibility. When I got to and read "... disks of infinite size coming free with a packet of corn flakes ...", I had a chuckle and left it there. I wouldn't personally have any problem if the old style package separator was removed permanently and completely.

        — Ken

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137715]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-01-27 09:02 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (70 votes). Check out past polls.