Camillo writes..
>Can anybody tell my why the sub routine def_store is not giving me the
>variable $store back if it runs as a service but it does when I run it
>in a regular perl script?
Holy cow, that's some crazy perl :)
I'd be really surprised if PerlSvc could install your service, you
haven't supplied $PerlSvc::Name and $PerlSvc::DisplayName. Perhaps
there's a version of PerlSvc that I don't know about, in any case,
PerlSvc probably does something with package variables that means that
your $store package variable is being localised or something like that.
I'm sorry, but I had to rewrite your script, I had to guess at what
$felder[19] was meant to be. I'm guessing that it was the size of the
file, but your split on the dir would mean that as soon as the file had
10 or more bytes then the size wouldn't be element 19 anymore, it'd be
element 18. When 100 or more then element 17, etc..
Anyway, here's my guess at a rewrite, it's untested - so sorry if there
are any bugs, it's also written for PerlSvc version 2.0. But it should
work with later versions as well. Hope it helps.
I think it's accurate except that I also output the filename in the log
file:
package PerlSvc;
our $Name = 'vrsvc';
our $DisplayName = 'Visual Receipt';
use constant SECONDS_IN_DAY => 24 * 60 * 60;
sub Startup
{
open LOG, '>>C:/ser.log' or die;
select( (select(LOG),$|=1)[0]);
while (ContinueRun(20))
{
my($d,$m,$y) = (localtime(time - SECONDS_IN_DAY))[3..5]; $y+=1900;
$m++;
my $datestamp = sprintf('%d%02d%02d' => $y,$m,$d);
my $dir = 'L:/sus';
unless( opendir DIR, $dir )
{
warn qq(Bad opendir of "$dir": $!);
next;
}
foreach my $file ( grep { -f } readdir DIR )
{
my $size = -s "$dir/$file";
print LOG "$datestamp $file $size\n" if $size > 1000;
}
closedir DIR;
}
close LOG;
}
sub Install {
# add your additional install messages or functions here
print "\nAdditional install notes\n";
}
sub Remove {
# add your additional remove messages or functions here
print "\nAdditional remove notes\n";
}
sub Help {
# add your additional help messages or functions here
print "\nAdditional help notes\n";
}
__END__
--
Jason King
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs