my $port = verify_port($value); sub verify_port { my $candidate = shift; if ( [suitable] ) { return $candidate; } else { (handle error case) (abort execution) } }