in reply to Interfacing a C program with Perl functions and modules

I'm trying to use the Perl Tk module to display data from an existing program. I've been able to call a Perl function from C and pass scalar and string data correctly, but I'm having problems with passing arrays by reference and with linking in the Tk and Class::Struct modules.

Maybe I'm wrong, but it seems easier (and more correct) to have the GUI program do one of the following: (1) Call C library functions directly, (2) Parse the output of the C program, or (3) Use IPC through pipes, sockets, memmap'd files, etc.

This would leave your code a lot cleaner than tieing Perl and C together the hard way. If you have a C library you want to use and can tolerate having compilers required, Inline::C (which I've only just started to play with) is a joy to use...either way, it seems to make more sense (to me) to put the higher level language (in this case, Perl) on the top of the software stack and let it call the C, rather than the other way around.

  • Comment on Re: Interfacing a C program with Perl functions and modules

Replies are listed 'Best First'.
Re: Re: Interfacing a C program with Perl functions and modules
by Anonymous Monk on Feb 18, 2004 at 22:52 UTC
    This would be simpler if I was writing the program from scratch. The problem is that this is an existing program, written by someone else, that is command-line-driven with a Unix-XWindows-C graphical interface to display data fitting results. I just want to replace the XWindows drawing utilities with something less platform-specific....

    To make things even more interesting, the calculation program is written in FORTRAN. I'm planning to use C wrapper functions to mesh the FORTRAN with the Perl rather than try to directly call Perl from FORTRAN. I'll stick to the existing function call format rather than muck around with the FORTRAN.

    Thanks,
    Diane.

      Sounds like it anyways. LANL, perhaps?
        Actually, a National Research Center at Cornell, ACERT. Check the website if you're curious.

        (http://www.acert.cornell.edu/)

        I'm upgrading the NLSL program available from the FTP page.