Michael -- > > > >> I just can't figure this out: how do I overwrite an exisitng file > >> without creating a new version? I.e., if x.;1 exists I want perl > >> to use that and replace the contents. But when I try that > >> I get: > > > >> $ perl -e "open(X,"">x.;1"") || die; printf X ""blabla""; > >> Died at -e line 1. > >> %RMS-E-FEX, file already exists, not superseded > > > > > >> I couldn't find anything in perldoc perlvms or the web, > >> please help. > > > >This whole idea makes me nervous. You seem to be trying to mimic Unix > >filesystem behavior,
> Actually, yes, I do while porting a Unix script (Vipul's Razor). Cool! Please let us know when you get it working. As far as I know, the only heuristic antispam on VMS is the still-in-beta payware that Process Software is working on, and I'm very unlikely to ever get funding for that for my fifty-or-so VMS mail users. [snippage of me bringing up stuff Michael already knows about] > > > >Enough angst. My best answer: > Don't be so `aengstlich'. Maybe I know what I am doing... Yeah, sounds like you do. I didn't mean to be patronizing, but I'm sorry I came across that way. > > > >I don't know if there's a special incantation that will make this happen; > >I know (from experience, and because it's what I usually want) that > >">> x" will append to an existing file or create a new one if it doesn't exist. > > > >But you could probably ">> x" and then do whatever the standard perl operation > >for truncate/erase/rewind is, and go from there. > Well, than rather set file/version=1. I mean, in something like Fortran, > that whole thing is a nobrainer. VMS can do this. But how with perl? I think maybe this is a bug in VMS Perl. I went searching on perldoc and came up with: http://www.perldoc.com/perl5.6.1/pod/perlfaq5.html #How-come-when-I-open-a-file-read-write-it-wipes-it-out- Which says: How come when I open a file read-write it wipes it out? Because you're using something like this, which truncates the file and then gives you read-write access: open(FH, "+> /path/name"); # WRONG (almost always) But: WINSTON>$ perl -e "open(X,""+> x.;1"") || die; printf X ""blabla""; WINSTON>$ perl -e "open(X,""+> x.;1"") || die; printf X ""blabla""; Died at -e line 1. %RMS-E-FEX, file already exists, not superseded Alternatively, it says: To open file for writing, create new file if needed or else truncate old file: open(FH, "> $path") || die $!; sysopen(FH, $path, O_WRONLY|O_TRUNC|O_CREAT) || die $!; sysopen(FH, $path, O_WRONLY|O_TRUNC|O_CREAT, 0666) || die $!; which is what you're trying (in the first case), and it doesn't work, and what I'm trying here: WINSTON>type tryit.pl use Fcntl; $path = "x.;1"; sysopen(X, $path, O_WRONLY|O_TRUNC|O_CREAT, 0666) || die $!; printf X "blabla"; WINSTON>perl tryit.pl WINSTON>perl tryit.pl file exists at tryit.pl line 3. %RMS-E-FEX, file already exists, not superseded So, still no help, but this does seem to be 5.6.1 on VMS (from the prebuilt, incidentally) not behaving as documented in this area. -- Alan -- =============================================================================== Alan Winston --- [EMAIL PROTECTED] Disclaimer: I speak only for myself, not SLAC or SSRL Phone: 650/926-3056 Paper mail to: SSRL -- SLAC BIN 99, 2575 Sand Hill Rd, Menlo Park CA 94025 ===============================================================================
