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

I am attempting to use the Win32::LanMan module to manipulate NT services. If I use the following in the main script, it works fine:
Win32::Lanman::EnumServicesStatus("\\\\$host","",&SERVICE_WIN32,&SERVI +CE_STATE_ALL,\@services)
If I move it to a subroutine I encounter the error:
Undefined subroutine &main::SERVICE_WIN32 called at D:\scripts\rcmd\rc +mdDisable.pl line 94.
I'm declaring LanMan with: use Win32::Lanman;
Help!

Replies are listed 'Best First'.
Re: Win32::LanMan
by AvignonHermit (Initiate) on May 29, 2003 at 19:18 UTC
    Never mind...
    Win32::Lanman::EnumServicesStatus("\\\\$host","",&Win32::Lanman::SERVI +CE_WIN32,&Win32::Lanman::SERVICE_STATE_ALL,\@services)
Re: Win32::LanMan
by Jenda (Abbot) on Jun 25, 2003 at 19:17 UTC

    The module is names "Win32::Lanman". Notice the lowercase "m". Are you sure you have

    use Win32::Lanman;
    and not
    use Win32::LanMan;
    or something on top of your script? Perl is case sensitive. And if the filesystem is not the use statement seems to work even if you type an incorrectly cased name. Just the functions, constants and variables are not exported.

    Also ... it's more efficient to write the constants without the &.

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature