jack martin <[EMAIL PROTECTED]> wrote:
<snip!>
> I'm running into a problem in the code which is
> reproducible in the piece of code below also.
<snip!>
> open(LGFILE,"> $Name") or
> die " Could not open $Name\n" ;
> #seed some data into the file
> print LGFILE "vbvbe\n";
> while ($line =<LGFILE>)
<and so forth ...>
Okay, I'll bite. Why are you trying to read your log file? You opened it
for output in the "open" at the beginning of the code snippet, wrote to it
(successfully, I believe!) at the subsequent "print", and then (at the
"while") started reading the same file you were writing. This is guarantted
to tie anyone in knots.
My best guess is that you are trying to use the same filehandle for two
different files. This will _never_ do what you expect. Based on this guess,
and assuming that at this point you're trying to nail file I/O, I suggest
something like
$Name = "logfile.txt";
open(LGFILE,"> $Name") or
die " Could not open $Name\n" ;
#seed some data into the file
print LGFILE "vbvbe\n";
for (print "enter data> "; $line = <STDIN>; print "enter more data> ")
{
print LGFILE "vbvbe\n";
}
close (LGFILE);
This will log "vbevbe" once, plus one for every data line you enter. Exit
the script with the e-o-f character (control/z under windows). If you
actually want to see your input in the log file, change
print LGFILE "vbvbe\n";
to
print LGFILE $line;
Tom Wyant
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs