home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl_ste.zip / auto / URI / URL / base.al < prev    next >
Text File  |  1997-11-28  |  868b  |  29 lines

  1. # NOTE: Derived from ./blib/lib/URI/URL.pm.  Changes made here will be lost.
  2. package URI::URL;
  3.  
  4. # Access some attributes of a URL object:
  5. sub base {
  6.     my $self = shift;
  7.     my $base  = $self->{'_base'};
  8.  
  9.     if (@_) { # set
  10.     my $new_base = shift;
  11.     $new_base = $new_base->abs if ref($new_base);  # unsure absoluteness
  12.     $self->{_base} = $new_base;
  13.     }
  14.     return unless defined wantarray;
  15.  
  16.     # The base attribute supports 'lazy' conversion from URL strings
  17.     # to URL objects. Strings may be stored but when a string is
  18.     # fetched it will automatically be converted to a URL object.
  19.     # The main benefit is to make it much cheaper to say:
  20.     #   new URI::URL $random_url_string, 'http:'
  21.     if (defined($base) && !ref($base)) {
  22.     $base = new URI::URL $base;
  23.     $self->_elem('_base', $base); # set new object
  24.     }
  25.     $base;
  26. }
  27.  
  28. 1;
  29.