Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello,
I have the END{} block on some module.
It is use()d by some script, to 'todo' script.
The 'preload' script does the do() on it. Both execute the code in the context of the package main;
The 'preload' script fork()s then and the compiled module's machine code is shared among the forks.
The problem is: if I put the 'use module;' or 'do "module.pm";' on the 'preload' script no matter if it is before the do() of the todo.pl or after, the END{} of the module gets to be executed twice.
I suppose there should be the built-in variable that keeps the used modules each time they use to be loaded. This is not the %INC because the module.pm is the key of that hash.
There is certainly a condition on the rest of the code that influenced the code to behave like that, I could not reproduce all of that at the moment being with the vanilla plain module, todo and preload files to put them here as a simple sample of the code. Although the reproduceable code itself is a no secret at all. I am sure it should be obvious for some kind Monk to know such a stuff. ;-)
Thank you.
Peter Vereshagin peter@vereshagin.org http://vereshagin.org

In reply to Pkg::END{} executes 2+ times, on how many times use Pkg; or do Pkg.pm; by petr999

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others browsing the Monastery: (3)
    As of 2024-07-25 09:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?
      erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.