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

I read what was out there and I have to ask you, the Elders about this one

I have a main.h file which I successfully converted to a MAP::Vars module with h2xs.

Now, that I have this module and I get no complaints when I do use MAP::Vars in my script, how do I actually access all the variables set up in the main.h file?

This is my script, and I need help understanding how to use the variables/constants set by the .h file

#!/usr/bin/perl use MAP::Vars; #EnStatus { #St_NetOnNorm print "Hello World! EnStatus{St_NetOnNorm} = $EnStatus{St_NetOnNorm} \ +n"; exit;

After this one, I'm donating perlmonks a 1000 Russian roubles (~$40), which is a lot for me here in Russia! Many thanks! And here is the huge main.h file: http://pashanoid.ru/main.h

Replies are listed 'Best First'.
Re: using a module created from C header file with h2xs
by Anonymous Monk on Jul 18, 2011 at 12:14 UTC
    This works for me:
    $ h2xs main.h $ mv main.h Main $ cd Main $ perl Makefile.PL $ make $ perl -Mblib \ -MMain=St_NetOnNorm,St_ProgMode,St_ProgEdit \ -E'say for St_NetOnNorm,St_ProgMode,St_ProgEdit' 1 2 4
    The module exports the header symbols. Read a book about XS and the Perl documentation about exporting.

      ok, so then from within a script I would do $var=Main->St_NetOnNorm?

Re: using a module created from C header file with h2xs
by jethro (Monsignor) on Jul 18, 2011 at 16:55 UTC