Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Use of do() to run lots of perl scripts

by shmem (Chancellor)
on Mar 03, 2021 at 00:26 UTC ( [id://11129045]=note: print w/replies, xml ) Need Help??


in reply to Use of do() to run lots of perl scripts

it make sense to modify my application so that worker perl scripts are invoked via do() instead of system calls?

Giving bad advice is difficult to avoid if the situation isn't clear, in this case: of what kind are the performance issues? Memory, responsiveness, load of the server?

do file reads a file and executes it. That happens in an unrelated scope with regards to the main script, but that can stomp on global variables or those declared with our, re-define subroutines and whatnot. So all of these 500+ scripts must be revised to check these issues before executing them via do.

Having done that, I would make each script into a file containing just a distinct subroutine, and have them executed via AutoLoader. See POSIX for an example. If memory is an issue, I'd use AutoReloader, keep track of invocation time and memory usage, and periodically unload (via an alarm handler) those scripts (now subroutines) which are seldom used and/or cause the most memory impact.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Use of do() to run lots of perl scripts
by Anonymous Monk on Mar 03, 2021 at 00:51 UTC
     do file reads a file and executes it. That happens in an unrelated scope with regards to the main script,

    Same scope is same scope

Log In?
Username:
Password:

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

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

    No recent polls found