# host_base set from 'host' when host_mask is set; Example: # if host_base==www.first.host & hostmask gets us "first.host" # i.e. hostmask would be only looking at the last 2 domainname-parts # in future matches, a host would first have the mask applied # (masking off a 3rd level sub-domain part), then match against # first_host .. resulting in a match if # that's subtracted from future relative saved paths. our ($pkg_host_mask, $pkg_host_base); our $items_from_cache=0; our $Cache_Control; sub host_mask (;$) { my $p = shift; return $pkg_host_mask if $pkg_host_mask; $pkg_host_mask = $_[0] if @_; $pkg_host_mask } sub host_base(;$) { my $p = shift; my $reset=1 if @_ && EhV shift, reset; return $pkg_host_base if $pkg_host_base && ! $reset; if (@_) { $pkg_host_base=$_[0]; } elsif ($p->host && $pkg_host_mask) { P "pkg_host_mask=%s, host=%s", $pkg_host_mask: $pkg_host_base = ($p->host =~ m{($pkg_host_mask)}) [0]; } return $pkg_host_base; } # returns empty-string if same site, or sitename+dir_sep if not; # caches result in {host_path} sub host_path { my $p = $_[0] or return undef; my ($host_base, $host_mask) = ($p->host_base, $p->host_mask); $host_base && $host_mask && $p->host or die P "Can't produce host_path w/o host_base( host(%s) & mask(%s) )", $p->host, $host_mask. ( ($p->host =~ m{$host_mask/})[0] eq $host_base ) ? '' : $p->host; }