On Thu, 16 Sep 2004, Anish Kumar K. wrote: > $filename = "data_logfile" .(localtime). ".txt"; > open(LOG, ">>$filename") || die "cannot append: $!"; > > > when I compile the file it says "Invalid argument". This is because of > the colon character.
It is? Why? That colon looks pretty innocent to me, What is the whole program -- or rather, what is the shortest whole program that shows the error -- and what is the full error? > Suppose after one activity I want to update the log activities in one > file say data_logfileTIME.txt > > What is the format? I don't understand this question. If you just want to add to the log file each time you go over this code, the open(...) statement you have is about right, because you're using the ">>" syntax, which appends to the file in question. On the other hand, I'm not sure if your file name is what you mean for it to be. You're going to end up with a different file name every time the code is executed: % perl -le '$filename = "data_logfile" .(localtime). ".txt"; print $filename' data_logfileThu Sep 16 08:49:38 2004.txt % perl -le '$filename = "data_logfile" .(localtime). ".txt"; print $filename' data_logfileThu Sep 16 08:49:39 2004.txt % perl -le '$filename = "data_logfile" .(localtime). ".txt"; print $filename' data_logfileThu Sep 16 08:49:40 2004.txt % perl -le '$filename = "data_logfile" .(localtime). ".txt"; print $filename' data_logfileThu Sep 16 08:49:41 2004.txt You probably want to at least strip the spaces out of that, and I doubt you really want a new log file every second, so you may want to strip out the timestamp as well. Look up the documentation for formatting dates to see how to turn this into something more stable. I suspect that once you have a stable log file name, the code to append to that log file will begin to behave. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>