Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Net::Ping blowed my mind

by rnewsham (Curate)
on Jun 13, 2015 at 21:06 UTC ( #1130323=note: print w/replies, xml ) Need Help??

in reply to Net::Ping blowed my mind

Welcome to the monastry, you need to chomp $url to remove the newline from the end of the url.

It is also highly recommended that you use strict and warnings, believe me it is well worth it.

Here is a modified version of your script which includes a print before and after a chomp to highlight the difference.

use strict; use warnings; use Net::Ping; my $url = <>; print ":$url:\n"; chomp($url); print ":$url:\n"; my $p = Net::Ping->new(); if ( $p->ping($url) ) { print "working\n"; } else { print "not working\n"; }
Output: : working

Replies are listed 'Best First'.
Re^2: Net::Ping blowed my mind
by jack298 (Initiate) on Jun 13, 2015 at 21:12 UTC
    Thank you so much it worked, I will try to ask harder next time, I am learning java in the school and Perl has some unusual codes for me:)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2021-09-23 09:47 GMT
Find Nodes?
    Voting Booth?

    No recent polls found