troubleshooting Question

Ways of calling another perl script

Avatar of Mazdajai
MazdajaiFlag for United States of America asked on
PerlScripting Languages
12 Comments1 Solution514 ViewsLast Modified:
I understand there are multiple ways to call another script within a perl script - system(), require(), use(), do().

Looking at the man page, my opinion seems like require() is preferred. On a modern perl perspective, would that be true?

In my example, I have many scripts that would like to call a email script with NET::SMTP,
use Net::SMTP;

my $infile = 'body.txt';
open(INFILE,"< $infile");
@file = <INFILE>;
close INFILE;
my $smtp_host = '';
my $from = "host1";
my $to = '';
if (length($ENV{HOSTNAME} ne "")) {$machine = $ENV{HOSTNAME};}
else {$machine = $ENV{COMPUTERNAME};}
my $subject = "Server(s) with corrupt file system records";
my $smtp = Net::SMTP->new($smtp_host,Timeout=>30,Debug=>1);
To: $to
#Bcc: $to
From: $from
Subject: $subject


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros