Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.5 KiB

  1. package AnyDBM_File;
  2. use vars qw(@ISA);
  3. @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
  4. my $mod;
  5. for $mod (@ISA) {
  6. if (eval "require $mod") {
  7. @ISA = ($mod); # if we leave @ISA alone, warnings abound
  8. return 1;
  9. }
  10. }
  11. die "No DBM package was successfully found or installed";
  12. #return 0;
  13. =head1 NAME
  14. AnyDBM_File - provide framework for multiple DBMs
  15. NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
  16. =head1 SYNOPSIS
  17. use AnyDBM_File;
  18. =head1 DESCRIPTION
  19. This module is a "pure virtual base class"--it has nothing of its own.
  20. It's just there to inherit from one of the various DBM packages. It
  21. prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
  22. L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
  23. finally ODBM. This way old programs that used to use NDBM via dbmopen()
  24. can still do so, but new ones can reorder @ISA:
  25. BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
  26. use AnyDBM_File;
  27. Having multiple DBM implementations makes it trivial to copy database formats:
  28. use POSIX; use NDBM_File; use DB_File;
  29. tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
  30. tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
  31. %newhash = %oldhash;
  32. =head2 DBM Comparisons
  33. Here's a partial table of features the different packages offer:
  34. odbm ndbm sdbm gdbm bsd-db
  35. ---- ---- ---- ---- ------
  36. Linkage comes w/ perl yes yes yes yes yes
  37. Src comes w/ perl no no yes no no
  38. Comes w/ many unix os yes yes[0] no no no
  39. Builds ok on !unix ? ? yes yes ?
  40. Code Size ? ? small big big
  41. Database Size ? ? small big? ok[1]
  42. Speed ? ? slow ok fast
  43. FTPable no no yes yes yes
  44. Easy to build N/A N/A yes yes ok[2]
  45. Size limits 1k 4k 1k[3] none none
  46. Byte-order independent no no no no yes
  47. Licensing restrictions ? ? no yes no
  48. =over 4
  49. =item [0]
  50. on mixed universe machines, may be in the bsd compat library,
  51. which is often shunned.
  52. =item [1]
  53. Can be trimmed if you compile for one access method.
  54. =item [2]
  55. See L<DB_File>.
  56. Requires symbolic links.
  57. =item [3]
  58. By default, but can be redefined.
  59. =back
  60. =head1 SEE ALSO
  61. dbm(3), ndbm(3), DB_File(3)
  62. =cut