JLW, perl -pi -e 's/foo/bar/' my_file.txt is supposed to do an inplace edit of my_file.txt, looping over each line, replacing foo with bar. Instead it merely stomps my_file.txt, effectively erasing it. Any body know why? Perl for cygwin, WinNt is the environment. David "Jeff Westman" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I got a priveate response to this posting, that may answer my original > question about using the mode "+<". > > "I knew I ran into this before, just could not remember where. From the > docs (perlfunc open): > ********************************* > You can't usually use either read-write mode for updating textfiles, > since they have variable length records. See the -i switch in the perlrun > manpage for a better approach. > *********************************" > > In the mean time, I simply wrote to a file then moved it back to the > original. > > Perhaps extending on this idea, what if the original file gets updated in > the interrum? Does Perl support fflock() ? > > Cheers, > > JLW > > > > --- Paul Kraus <[EMAIL PROTECTED]> wrote: > > open FILEHANDLE ("</path/file"); Input > > > Output > > >> Append > > > > I have never used +< I am assuming that this somehow uses the same file > > for STDIN and STDOUT? > > > > > -----Original Message----- > > > From: Mystik Gotan [mailto:[EMAIL PROTECTED]] > > > Sent: Tuesday, December 17, 2002 2:45 PM > > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > > Subject: Re: Read-Write Mode Not Working > > > > > > > > > Yes, I am having the same problem. I don't write much scripts > > > (I'm a newbie) > > > but when I do, open() doesn't seem to work. I'm pretty sure > > > it has to work > > > on Windows, but... > > > > > > -------------- > > > Bob Erinkveld (Webmaster Insane Hosts) > > > www.insane-hosts.net > > > MSN: [EMAIL PROTECTED] > > > > > > > > > > > > > > > >From: Jeff Westman <[EMAIL PROTECTED]> > > > >To: [EMAIL PROTECTED] > > > >Subject: Read-Write Mode Not Working > > > >Date: Sun, 15 Dec 2002 11:20:28 -0800 (PST) > > > > > > > >Hi, > > > > > > > >I'm using ActivePerl 5.6.1. I am trying to update an existing file. > > > >According to perlfaq5.pod, I should be able to use: > > > > > > > > open(FH, "+< /path/name"); # open for update > > > > > > > >However, I this doesn't seem to update the file for me: > > > > > > > >#----------(begin)---------# > > > >#! perl -w > > > >$| = 1; > > > >$file = "myFile"; > > > >open(FILE, "+< $file") or die "Could not open file, $file: > > > $!\n"; while > > > >(<FILE>) { > > > > # do whatever (read) > > > > print; > > > >} > > > > > > > ># write a line to the file > > > >print FILE "\ntest line\n"; > > > >close(FILE); > > > >#----------(end)-----------# > > > > > > > >This runs and displays the file, but the added line is missing. Any > > > >ideas why?! Thanks in advance. > > > > > > > > > > > >Jeff > > > > > > > >__________________________________________________ > > > >Do you Yahoo!? > > > >Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > > > >http://mailplus.yahoo.com > > > > > > > >-- > > > >To unsubscribe, e-mail: [EMAIL PROTECTED] > > > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > _________________________________________________________________ > > > Ontvang je Hotmail & Messenger berichten op je mobiele > > > telefoon met Hotmail > > > SMS http://www.msn.nl/jumppage/ > > > > > > > > > -- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]