home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / perl / 7040 < prev    next >
Encoding:
Text File  |  1992-11-18  |  2.5 KB  |  81 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!mcsun!chsun!bernina!neptune!weingart
  3. From: weingart@inf.ethz.ch (Tobias Weingartner)
  4. Subject: DBM stuff random?
  5. Message-ID: <1992Nov18.162917.4712@neptune.inf.ethz.ch>
  6. Followup-To: comp.lang.perl
  7. Keywords: DBM
  8. Sender: news@neptune.inf.ethz.ch (Mr News)
  9. Nntp-Posting-Host: tau.inf.ethz.ch
  10. Reply-To: weingart@inf.ethz.ch
  11. Organization: ETH - Switzerland
  12. Date: Wed, 18 Nov 1992 16:29:17 GMT
  13. Lines: 66
  14.  
  15. This one has me baffeld.  I have a piece of code,
  16. that updates a dbm file (dbmopen....), and also
  17. the ASCII version of this file.
  18.  
  19. The ASCII version gets updated with no problem.
  20. The DBM version does not seem to get updated.
  21.  
  22. However, IF I DO the updating using the debugger
  23. (perl -d) everything works.  I don't mean if I
  24. step though the code, but if it type in:
  25.  
  26. perl -de 0
  27.  
  28. And then do the dbmopen(...);$FOO{...} = BAR;dbmclose(..);
  29.  
  30. If anyone can see where I have gone wrong in the following
  31. excerpt, please pound me on the noggin.  I know, this ain't
  32. pretty code, but I AM in the process of munging into something
  33. a little better...
  34.  
  35. #
  36. # Open and update ASCII file
  37. #
  38.         open(UDB, "<$udb_data") || return "Open $!.";
  39.         chop(@udb = <UDB>);
  40.         close(UDB);
  41.  
  42.         @udb = grep(!/^$user:/, @udb);
  43.         push(@udb, join(':', @uinfo));
  44.  
  45.         open(UDB, ">$udb_data") || return "Open $! $udb_data.";
  46.         for(@udb){
  47.                 print UDB "$_\n";
  48.         }
  49.         close(UDB);
  50.  
  51. #
  52. # Open and update both DBM files.
  53. #
  54.         dbmopen(BYU, "$udb_by_u", undef) || return "Open $! $udb_by_u.";
  55.         dbmopen(BYN, "$udb_by_n", undef) || return "Open $! $udb_by_n.";
  56.  
  57.         $BYU{$user} = join(':', @uinfo);        # Don't work, WHY???
  58.         $BYN{$uinfo[1]} = join(':', @uinfo);    # Don't work, WHY???
  59.  
  60.         dbmclose(BYU);
  61.         dbmclose(BYN);
  62.  
  63.  
  64. I'm lost!
  65.  
  66. --Toby.
  67.  
  68. ***************************************************************
  69. * Tobias Weingartner  * Not every man is willing to die...    *                
  70. * c/o Bruno Opprecht  * Some have to be PUSHED out the window *
  71. * Oberdierikoner st.7 * ------------------------------------- *                
  72. * 6030 Ebikon Luzern  *  Anybody who dictates that computers  *
  73. * SWITZERLAND         *        are logical, I'll ...          *                
  74. ***************************************************************
  75. * +41'041'33'25'40    * ..Midnight the fading, blue Wizrd..   *
  76. ***************************************************************
  77. SYSTEM-F-ANARCHISM, the operating system has been overthrown                  
  78.  
  79. PGP2.0 Public Key available at 'finger weingart@tau.inf.ethz.ch'
  80.  
  81.