suhailck has asked for the wisdom of the Perl Monks concerning the following question:

I want to make a daemon in windows for the below task. I'm not clear about how to install Win32::Dameon and use it properly. Please advice me

use strict; my $file="abc786"; while(1) { if (-s $file > 0) { open(my $in,"+<",$file) or die "$!"; print STDOUT <$in>; seek($in,0,0); truncate($in,0); } sleep 1; }


Thanks,
Suhail

Replies are listed 'Best First'.
Re: Win32::Daemon help
by Anonymous Monk on Jul 27, 2011 at 06:35 UTC
Re: Win32::Daemon help
by Marshall (Canon) on Jul 27, 2011 at 21:47 UTC
    A daemon makes no sense. daemon's (in Windows lingo, a service) does not read STDIN or write STDOUT - it has no means of doing so. A daemon is a process that is running without a console - other programs communicate with it by other means.

    It appears that you are desiring to periodically delete the data in some kind of log file. At most you would need to just use the process scheduler in Windows. But I doubt you even need that.

    Find whatever is creating this "abc786" file and have it write to the file "NUL" instead. This will look like a normal file which can be opened and written to, but the contents are just discarded (never written to disk in the first place). Data just disappears, no Perl script, no problem.