CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Using Ping module in perl


New User

Mar 31, 2014, 12:48 PM

Post #1 of 2 (1807 views)
Using Ping module in perl Can't Post

Hi everybody!

Recently i've begun to program with perl, and i've stumbled accros two main issues which i couldnt solve myself:

1) First, i got a task to simulate the tracert command (from windows) in perl code. i've tried "cheating" by using qx(ping -i n) but ping doesnt give me the ms, which i need.

To the subject, i've been messing around abit with the Net::Ping module but i've had a hard time understanding how to use it. I wanna know if there's a way with this module to achieve what i want, which is pinging with a different ttl each time until i reach the destination address, and getting the ms of each ping.

2)Another problem i had is kinda weird. I've tried opening a file from a path recieved by user input. This is the code that i've written:

my $strPath = <>; 
open(my $fh, "<", $strPath)

But it gives me an error when i run it (Invalid Parameter). I've checked the variable with print after inserting a value to it, i've tried also writting the path hard-copied in both the variable and the function and it worked fine. anyone has a clue what the issue is?


Veteran / Moderator

Mar 31, 2014, 2:53 PM

Post #2 of 2 (1803 views)
Re: [Katnopic] Using Ping module in perl [In reply to] Can't Post

No idea for the first question, I am not using this type of commands under Windows.

For the second one, if you are expecting user input, you probably want something like this:

my $strPath = <STDIN>;  
chomp $strPath;
open(my $fh, "<", $strPath) or die "could not open $strPath $!";


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives