Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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: :www.bbc.co.uk : :www.bbc.co.uk: 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2020-11-26 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?