http://qs321.pair.com?node_id=1130323


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:)