From: [EMAIL PROTECTED]
> I have a problem giving a Parameter to a module. The Module is invoked
> like this:
> 
> use Win32::Daemon::Simple
>  Service => 'Logrotate',
>  Name => 'Logrotate',
>  Version=>'0.1',
> Info => {
>                         display =>  'Logrotate',
>                         description => 'Logrotate',
>                         user    =>  '',
>                         pwd     =>  '',
>                         interactive => 0,
>    path    =>  "$Bin\\$Script",
>         #               parameters => "$Bin\\$Script",

Remove the two lines above ! You do NOT want to set the path=> 
yourself, leave this to the module!

>                 },
> Params => {
>                         Tick => $debug_on,

The problem is caused by the order of execution.
The use statements are executed (and the import() function of the 
module called) as soon as they are compiled. before the normal code 
in the script gets a chance to execute.

Therefore if you wrote

        $debug_on = 1;
        use Win32::Daemon::Simple ...

the $debug_on variable is NOT set to anything when the module does 
it's dirty work. You have to do it like this:

        BEGIN { $debug_on = 1; }
        use Win32::Daemon::Simple ...

The reason is that I want to give you the parameters as CONSTANTS 
instead of as variables and I want them to be known as constants when 
the rest of your script gets compiled.
This is especialy good for things like

        print "Some debugging data\n" if CMDLINE;

If the CMDLINE constant has a false value the whole statement will be 
optimized away during compilation.

I'll have to improve the docs :-)

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to