简体   繁体   中英

calling perl script with system VS implementing package

Let me start with giving an example of what I'm dealing with first:

I often call existed Perl scripts from previous engineers to process some data, and then proceed further with my script. I either use system or back-ticks to call other people scripts within my script.

Now, I'm wondering if I rewrite those scripts as packages and use require or use to include those packages in my script, will it increase the processing speed? How big of a difference would it be?

Benefits:

  • It would save the time taken to load the shell, load perl , compile the script and the module it uses. That's a couple of seconds minimum , but it could be much larger.
  • If you had to serialize data to pass to the child, you also save the time taken to serialize and deserialize the data.
  • It would allow more flexible interfaces.
  • It would make error handling easier and more flexible.

Downsides:

  • Since everything is now in the same process, the child can have a much larger effect on the parent. eg A crash in the child will take down the parent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM