home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _a24c29fd6b066c9ac2dc4d9c117ecc0e < prev    next >
Encoding:
Text File  |  2004-06-01  |  994 b   |  46 lines

  1. package PPM::Archive;
  2.  
  3. use strict;
  4.  
  5. sub new {
  6.     my $self = shift;
  7.     my $file = shift;
  8.     my $o    = bless {
  9.     file    => $file,
  10.     }, ref($self) || $self;
  11.     $o->select_handler;
  12.     $o->load;
  13.     return $o;
  14. }
  15.  
  16. sub rebless {
  17.     my $self = shift;
  18.     my $obj  = shift;
  19.     bless $obj, ref($self) || $self;
  20. }
  21.  
  22. sub select_handler {
  23.     my $o = shift;
  24.     my $f = $o->{file};
  25.     if ($f =~ /\.(?:tar(?:\.gz)?|tgz)$/i) {
  26.     require PPM::Archive::Tar;
  27.     PPM::Archive::Tar::->rebless($o);
  28.     }
  29. # Compress::Bzip2 doesn't yet compile or pass its 'make test', so we probably
  30. # shouldn't support it yet. I'll contact the author and see if he's actually
  31. # maintaining the module.
  32. #    elsif ($f =~ /\.tar\.(?:bz(?:ip)?2)$/i) {
  33. #    require PPM::Archive::Tar;
  34. #    PPM::Archive::Tar::->rebless($o);
  35. #    }
  36.     elsif ($f =~ /\.zip$/i) {
  37.     require PPM::Archive::Zip;
  38.     PPM::Archive::Zip::->rebless($o);
  39.     }
  40.     else {
  41.     die "Unsupported PPM archive format";
  42.     }
  43. }
  44.  
  45. 1;
  46.