in reply to Calling a sub-routine in CGI

Thanks everyone, I guess I'm going about this the wrong way! (see my code mid way down the page) As I said I'm still learning CGI, and this is my first undertaking. Is there a better way to execute the toggle_on command? If so what are my options?

The toggle_on comand in using the ControlX10 module from CPAN to activate some X10 components. Would it be better and less complicated to just create some sort of form and exexcute the command based on text input, or is it possible (I know anything is possible with Perl) to activate the sub-routine graphically (ie pushing a button, or clicking a hyperlink)?

Thanks again

Replies are listed 'Best First'.
Re: Re: Calling a sub-routine in CGI
by rinceWind (Monsignor) on Aug 09, 2002 at 13:57 UTC
    So, you are wanting a web frontend to control some device connected through a serial port. This seems to imply that the machine with the serial port is the same one as running the webserver (it may be that all your software is running on one box).

    I would suggest that you are biting off more in one go than you can chew.

    I would suggest starting by writing a command line Perl program to drive the X10 stuff. Write this program in a modular fashion with subs for each of the functions.

    Next think about your web interface. Design the front end forms and hyperlinks, and prototype how you want it to work.

    Now knock up a small CGI app to call your existing program functionality using system or backticks. You should now have a working application!

    Finally, rewrite the CGI application to call the code directly.

    Hope this helps,

    --rW

      Thanks, I have completed your recommendation previously, but I'm having trouble calling the sub-routines via the CGI script. See code several posts above.

      I guess I will have learn some more CGI before I can proceed, thanks again everyone, you've given me plenty of ideas