sub check_mobiletype { my $destination = shift; if($destination =~ /^\+/ && $destination !~ /^\+{1}.*\D/) { my $id = get_contacts_id_by_mobilephone($destination) or return; my $phone = get_mobilephone($id) or return; return ($id, $phone); } elsif($destination =~ /\d/ && $destination !~ /\D/) { my $id = $destination; my $phone = $tcrm->get_mobilephone($id) or return; return ($id, $phone); } return; } my ($id, $phone) = check_mobiletype($destination) or die "ID not found";