home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / perl / 5788 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.0 KB  |  43 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!uvaarpa!mmdf
  3. From: Martin {martlbub} Kraegeloh <krm@pri-mu.prime.com>
  4. Subject: problems opening a file read/write
  5. Message-ID: <1992Sep9.094428.16363@uvaarpa.Virginia.EDU>
  6. Sender: mmdf@uvaarpa.Virginia.EDU (Mail System)
  7. Reply-To: krm%pri-mu.LOCAL@pri-mu.prime.com
  8. Organization: The Internet
  9. Date: Wed, 9 Sep 1992 09:44:28 GMT
  10. Lines: 31
  11.  
  12. Hi net,
  13.  
  14. I tried the following small piece of code:
  15.  
  16. --------------------------------
  17. #!/bin/perl
  18. open(TEST,"+>tst")||die "open";
  19. while($_=<TEST>){
  20.    if (/add/){
  21.       chop ;
  22.       $_.="ADD\n";
  23.    }
  24.    print TEST $_ || die "print";
  25. }
  26. close(TEST) || die "close";
  27. --------------------------------
  28.  
  29. Now the problem:
  30.  
  31. If I use open with "+>filename", the file will end up empty.
  32. If I use "+<filename", it will remain unchanged.
  33.  
  34. I guess I am doing sth. wrong, but WHAT IS IT ??
  35. (I checked the faq without success)
  36.  
  37. my perl version:
  38.  
  39. $RCSfile: perl.c,v $$Revision: 4.0.1.4 $$Date: 91/06/10 01:23:07 $
  40. Patch level: 10
  41.  
  42. Thanks, Martin
  43.