8/27/03 00:29:34, Alan Winston - SSRL Central Computing <[EMAIL PROTECTED]> wrote:

>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.  

I sort of do.  I just don't know razor yet so I am not sure if it
really works.  It detects some spam but doesn't do statistics.
Maybe it's just a configuration thing.

>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.

I got spamassassin hooked into MX 4.2.  Not ready for release yet.
I am trying to get this into the official spamasassin release.  But I
only get to it in my spare time. So it's still a while.  And I am learning
perl at the same time.  Kind of fun.

>
>[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.

No problem.  And I just realize my comment could be misunderstood
as well.  I just meant since I don't know razor (and perl) I am not so
sure I know what I am doing...

Ok, back to this problem:
>
>> >
>> >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.

Thanks for that.  So it seems to be bug.  I can confirm the beavior with
perl 5.8.0.  Further, omitting a version number I always get new versions.

Can we somehow sort this out?  I need to know what is supposed to
happen. Right now I rely on open to fail if the version exists for opening
a lock file, just as on Unix.  If the behavior changes as indicated above
this would fail and needs to be done differently.

Michael



Reply via email to