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

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?
  • Comment on Re^2: Can't get a simple log creator to work!

Replies are listed 'Best First'.
Re^3: Can't get a simple log creator to work!
by ikegami (Patriarch) on Feb 23, 2010 at 16:10 UTC

    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>;
Re^3: Can't get a simple log creator to work!
by ikegami (Patriarch) on Feb 24, 2010 at 05:31 UTC

    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)