in reply to html->perl->c->perl...... work dang it

Your global variables ($username, etc.) are being clobbered by the Command() subroutine after being set by the CGI input params. When called as a CGI, @ARGV will be blank. I suggest moving the CGI param fetching into a get_cgi_params() subrotine (or whatever you want to call it). Then check if @ARGV is defined. If it is, call Command(). If not, call get_cgi_params().

Also, you'll want to check into getting a templating system. HTML::Template is a very popular choice, but hardly the only one.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: html->perl->c->perl...... work dang it
by jcpunk (Friar) on May 15, 2003 at 16:50 UTC
    wow, i totally didnt realize i did that thanks
    unfortunatly with the change (commenting out the command sub call) it still shows no signs of running the C program or the secondary script... any ideas beyond that as to why?
    i will post up my adjusted code once i have written the approprate functions per your instructions
    thanks
Re: Re: html->perl->c->perl...... work dang it
by jcpunk (Friar) on May 15, 2003 at 16:55 UTC
    this replaced the head of the first perl script... still no luck in the area of getting it to jump throught my C program though.......
    #!/usr/local/bin/perl -wT use strict; use CGI; if ($#ARGV==0) { my $post_data=new CGI; my $username=$post_data->param('username'); my $on_off=$post_data->param('on_off'); my $message=$post_data->param('message'); } else { &Command(); } @junk = ("authorize", "vacation.pl", $username, $on_off, $message); $runme = join (" ",@junk); &Header();

      If an array is empty, ($#ARRAY == 0) is false. $#ARRAY is -1 for an empty array, because $#ARRAY returns the index of the last valid element, not the number of elements in the array. An array with one element has a last element of index zero.

      You can do your check for an empty argument list with any of the following: (not @ARGV), (0 == @ARGV), or ($#ARGV < 0). I prefer the first, but it's a matter of style.

      --
      [ e d @ h a l l e y . c c ]

        Thank you very much i will implement that