Ping in perl


how do you ping using perl? I know I can use bash by doing ` ` but how would I do it?

is it - Print "`ping` $ipAddress"

and how do I press return? `/r`?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulmulAuthor Commented:
That's not really what I need. Pinging isn't the important part, its just something I need to do, I need to know how to use bash and perl to ping an IP, it HAS to be done that way.
PaulmulAuthor Commented:
I worked out how to do what I needed.

Code is

print "Enter URL";
$url = <stdin>;
chomp $url;

$res = `ping "$url"`;

print "$res";
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

There are quite few questions in the database with examples of how to use Net::Ping.

But if they don't answer your question sufficiently, let us know here and we can try to be more clear.
I like:

@results = qx/ping $OPTIONS $HOST/;
Rather than delete, I recommend PAQ, but still refund points. Paulmul's solution is okay, and may be what is required for his situation, but it's important for askers to consider the "pure perl" approaches that do not explicity call out to external programs.
Here's a ksh and Perl (shellified version)

print "Enter URL"
read url

res=`ping $url`
print "$res"

print "Enter URL";

$res=`ping $url`;
print "$res";

However, some points to make:

You can't ping URL's, you can only ping IP addresses or hostnames (that resolve to an IP address).  
I see no point in writing a shell script as a Perl script.  If you are going to write a Perl script, write it as Perl not a pseudo shell script (one of my particular hobby horses).
AnnieMod, Agreed. ***Always read very carefully what the moderator posts.***

I had read the user's request to delete and failed to notice exactly which boilerplate notice you had responded with. Sorry.
It's been an active thread. Several people, including me, have posted something they wrote only to discover that more details had arrived while they were researching and writing.

Keep up the good work, everyone!
PAQed, with points refunded (50)

EE Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.