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

Hello folks again ....I have written a cgi script in which I am assigning all the user/form input to the hash reference %input now my task is to call a function defined in perl file located at the following location:

/view/sawans1_Ndb_0037_work/vobs/pp/pptai/api/NightlyDB/api_test.pl

the function's name is get_result and it takes hash reference created in the CGI script...I wants to print the return value throughthe CGI script...Kindly let me know how I can call such function

Thanks in advance !!!

  • Comment on Calling perl subroutine through CGI script

Replies are listed 'Best First'.
Re: Calling perl subroutine through CGI script
by ww (Archbishop) on Mar 04, 2010 at 21:44 UTC

    I'm so very sorry. Some prankster must have given you the Monastery's address when you were looking for a free codewriting service.

    WHYT?1 Where's your code? What problem(s) are you having with your attempt to solve this problem (Slow connections to the Monastery do NOT count.

    1: "What have you tried?"

Re: Calling perl subroutine through CGI script
by CountZero (Bishop) on Mar 05, 2010 at 07:22 UTC
    Three solutions:
    1. Put your sub-routine in your CGI-handling script.
    2. Load your script with do '/view/sawans1_Ndb_0037_work/vobs/pp/pptai/api/NightlyDB/api_test.pl'; and then call your sub-routine as usual.
    3. Put your subroutine in a proper module and use the module.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Calling perl subroutine through CGI script
by jrsimmon (Hermit) on Mar 04, 2010 at 22:00 UTC