I am under a situation where i am trying to get the current IP address with time. The code below works fine when there is connection of internet and it return the IP as desired.
my $address = 'Net::Address::IP::Local'->public ;
The problem is my code also has to run if there is No internet connection, so the problem occurs when i am disconnected and still run the same code it breaks my all code because there is no IP written by it as we are disconnected from internet
Now i have though some solution of it but out of luck!!!! The solution is wheni receive no IP address then i should assign a static IP address like this ($address='192.80.160.16';) But it do not work. My try to do it is below :
sub ReturnIpAddress { select STDOUT; my $address = 'Net::Address::IP::Local'->public ; ## Receiving the c +urrent IP ## if(!$address) { return $address='192.80.160.16'; ##If No IP address received then +return a static IP of order "192....." } else { return $address; } }
But it still do not work. When i try to print that IP adress on disconnect then it prints nothing (If it was like Null or 0 in c++ i could have handle it but i dont know how to handle it by doing something like this (if($address==null){ $address='192.80.160.16';}) in case of perl)
Any help please ?
In reply to How to handle Net::Address::IP::Local'->public when we are not connected to internet by ppp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |