in reply to Can't get a simple log creator to work!

You're opening the file twice, the second time using some arcane method.
#!/usr/bin/perl use 5.010; use strict; use warnings; my $fn_log = 'perlogfile.rtf'; open(my $fh_log, '>>', $fn_log) or die("Can't append to log file \"$fn_log\": $!\n"); print($fh_log $_) while <STDIN>;

Replies are listed 'Best First'.
Re^2: Can't get a simple log creator to work!
by aquinom85 (Initiate) on Feb 23, 2010 at 05:40 UTC
    thanks but it's not putting what i enter into terminal into that file. (but no wierd error that I don't understand at least) but this is *supposed* to send <STDIN> to $fh_log (what's the H for?) until end-of-file and append fh_log to fn_log correct?

      thanks but it's not putting what i enter into terminal into that file.

      Yes it does.

      >perl a.pl fasfd dsfdasfdasf dsafsdafdas fdasfdasfs ^Z >type perlogfile.rtf fasfd dsfdasfdasf dsafsdafdas fdasfdasfs

      Perhaps you are peeking at the file before you stop adding to it, in which case you are suffering from buffering. Fix:

      #!/usr/bin/perl use 5.010; use strict; use warnings; use IO::Handle qw( ); my $fn_log = 'perlogfile.rtf'; open(my $fh_log, '>>', $fn_log) or die("Can't append to log file \"$fn_log\": $!\n"); $fh_log->autoflush(1); print($fh_log $_) while <STDIN>;

      fh = file handle

      fn = file name. But it's actually used as a qualified file name, such as an absolute path (/foo/bar/file.txt) or a relative path (file.txt or baz/file.txt or ../qux/file.txt)