sub get_location_id { my ($loc_string, $vhost_id) = @_; # %locations is a global hash, the one that holds all the values return $locations{"$loc_string-$vhost_id"} if defined($locations{"$loc_string-$vhost_id"}; # OK, maybe we didn't find the whole thing, but we still # want to know what the top level of the tree was, # i.e. /foo/bar/ may not be in the lookup hash, but # if /foo/ is we want to log it my ($chopped_loc) = ($loc_string =~ m#^([^/]+/?#); return $locations{"$chopped_loc-$vhost_id"} if defined $locations{"$chopped_loc-$vhost_id"}; # OK, that handles it if the trailing slash is present # in the data ... return $locations{"$chopped_loc/-$vhost_id"} if defined{"$chopped_loc/-$vhost_id"}; # log it to the catch-all "other" location if # we've fallen through this far return $locations{"other-$vhost_id"}; }