Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"


by pwhysall (Acolyte)
on Feb 16, 2001 at 19:44 UTC ( #58866=note: print w/replies, xml ) Need Help??

in reply to Re: List of groups on Win32
in thread List of groups on Win32

But I have a problem with AdminMisc - it seemed to install OK, but every time I call my little program:
#!/usr/bin/perl -w

use Win32::AdminMisc qw(GetDC GetGroups);

my $dc;
my @groups;

$dc = GetDC();

GetGroups($dc, GROUP_TYPE_ALL, \@groups);

my $item;

foreach $item(@groups) {
  print "$item\n";                                          

I get an error message:

bash-2.02$ perl
"GetDC" is not exported by the Win32::AdminMisc module at line 3
"GetGroups" is not exported by the Win32::AdminMisc module at line 3
Can't continue after import errors at line 3
BEGIN failed--compilation aborted at line 3.

I'm not up on how perl modules and such work, so I don't know how to fix this :-(

Replies are listed 'Best First'.
Re: Thanks
by arturo (Vicar) on Feb 16, 2001 at 20:03 UTC

    First off: baku's given you a good fix

    Here's the 'why' ... Perl modules that export symbols usually use the Exporter module internally. Such modules maintain lists of symbols (names of variables and subroutines) they automatically export (@EXPORT) and ones that they may export if asked to (@EXPORT_OK). (exported symbols can be accessed without fully qualifying their names).

    The module you're using doesn't list either of the symbols you're asking it to export (with the qw() construct) in its list of exportable symbols, hence the error.

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: Thanks
by baku (Scribe) on Feb 16, 2001 at 19:56 UTC

    Try removing the qw[] block, and using the "qualified" names (like Win32::AdminMisc::GetGroups)... does that help any?

Win32:: modules (Re: Thanks)
by tye (Sage) on Feb 16, 2001 at 20:02 UTC

    I'm not up on how perl modules and such work,

    This can also be said for many authors of Win32:: modules. ): You'd think Dave Roth would know better by now, but perhaps it is just "history" for this particular module.

    A simple @EXPORT_OK= qw( list of subs ) would make this module easier to use (and fit the common expectations for a Perl module).

            - tye (but my friends call me "Tye")
Re (tilly) 1: Thanks
by tilly (Archbishop) on Feb 16, 2001 at 20:07 UTC
    Those messages indicate that the module uses Exporter but did not put those functions in @EXPORT_OK to indicate that they could be exported. I would first check the module's documentation to see whether you have the names correct (including documentation) and if you do I would just stop trying to import them and use them directly, or I would add the lines:
    *GetDC = *Win32::AdminMisc::GetDC; *GetGroups = *Win32::AdminMisc::GetGroups;
    to manually import. (Well I would also go into the module, add a patch, and then send a bug report to the author, but that is just me...)
      I'm literally amazed by the response. Mad props to all who took the time to reply.

      Unfortunately (?) I'm currently trapped in Linux (hehe) and so can't test the fixes that people have so very kindly suggested, but you can be sure that I will test them out and let you all know how it goes.

      Once again, many thanks.

      I'm literally amazed by the response. Mad props to all who took the time to reply.

      And now the bad news. I can't test this stuff today - I'm now in the Linux half of my job and Win32 stuff doesn't seem to want to work :-).

      You can be sure, however, that I will be testing out the ideas that have been so kindly offered here on Monday, and I will report back in the hope that my experiences will help someone else.

      Thanks again, everyone.

        As you can see, I have a memory like a sieve. I'd remembered that I wanted to say thanks, but had forgotten that I had :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://58866]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2020-09-25 03:48 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (136 votes). Check out past polls.