in reply to printing true false values

Change your return to
return ( $addr_to_check =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ ) ? 1 : 0;