----- Original Message ----- From: "John W. Krahn" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, February 10, 2002 10:03 AM Subject: Re: rename a file in win98
> > I have also tried using File::Copy but it doesnt copy the last line of the > > file. > > My file is created by printing single lines into a text file as follows.... > > open($MYFILE1, "+>> C:/sentslips/sentslipstemp.txt") > > || die "can't open C:/sentslips/sentslipstemp.txt"; > > > > print {$MYFILE1} "$filename?$date\n"; > > close (MYFILE1); > > > > This is inside a loop, so I end up with a file with (at the moment) 2-4 > > lines like so... > > Placing_Slip___This is the first?09-02-2002 > > Placing_Slip___This is the second?09-02-2002 > > > > but when I copy or move the file like this... > > > > copy("C:/sentslips/sentslipstemp.txt","C:/sentslips/sentslips1.txt"); > > > > the new file would have one less line, > > > > any help would be hugely appreciated. Thanks again > > > use File::Copy; > > open OLD, "< $old" or die "Cannot open '$old' $!"; > binmode OLD; > open NEW, "> $new" or die "Cannot open '$new' $!"; > binmode NEW; > copy( \*OLD, \*NEW ) or die "Cannot copy '$old' to '$new' $!"; > > Thanks John, This worked the first time, but when I tried it again, it copied one less line than it should?? Could it be something to do with newlines or eof or something?? Very confused! Thanks for your help, it sure keeps me sane! Chris. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]