Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: pp: modules disappearing while program runs?

by choroba (Cardinal)
on Apr 07, 2022 at 09:34 UTC ( [id://11142790]=note: print w/replies, xml ) Need Help??


in reply to pp: modules disappearing while program runs?

Wait, if the requires have already run, they won't do anything when run for the second time. Under the same name, a module can only be loaded once.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: pp: modules disappearing while program runs?
by pryrt (Abbot) on Apr 07, 2022 at 13:17 UTC
    What if you delete the %INC entry (delete $INC{'Blah/Blah.pm'} for removing Blah::Blah) before the second require ... In my experiments (*), that allows me to have the require work again:

    ./lib/Blah/Blah.pm:

    package Blah::Blah; use 5.012; # strict, // use warnings; $| = 1; print "Loading Blah::Blah at " . scalar(localtime) . "\n"; 1;

    ./example.pl:

    #!perl use 5.012; # strict, // use warnings; use lib './lib'; $| = 1; require Blah::Blah; print "example separator\n"; delete $INC{'Blah/Blah.pm'}; print "entry deleted\n"; sleep(2); require Blah::Blah; print "example separator\n";

    output:

    Loading Blah::Blah at Thu Apr 7 06:17:19 2022 example separator entry deleted Loading Blah::Blah at Thu Apr 7 06:17:21 2022 example separator


    Edit: add footnote: *: well, at the command line; I admit I didn't try in a pp executable

      Yes. Also the require happening in a child/thread.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-18 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found