|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I want to setup a single script that does multiple things. Is there anyway to do that?
like if the script is called /cgi-bin/script.cgi it runs one subroutine, but if it's called /cgi-bin/script.cgi?something it runs a different subroutine. Thanks! |
|
#2
|
|||
|
|||
|
Set up the script with a flag before any functions are reached.....then when linking to your script inclue the flags value when calling it......ie:
your call----> "/cgi-bin/script.pl?your_flag=do_this" your script-----> if ($your_flag eq 'do_this') { &do_subroutine } if ($your_flag ne 'do_this') { &do_main_function } hope that helps |
|
#3
|
|||
|
|||
|
you can parse the input given by calling this line first read(STDIN, $input, $ENV{'CONTENT_LENGTH'}); this line will read the inputs ie suppose if call a cgi like this /cgi-bin/call.cgi?dothis then $input have "dothis" .. then u can use the previous logic |
|
#4
|
|||
|
|||
|
Thanks for the help, but neither method seems to work.
|
|
#5
|
|||
|
|||
|
>>but neither method seems to work
Why not? You must have done something incorrectly to your script yourself. Anyway, try this example: ################################################# #!/usr/local/bin/perl print "Content-type: text/htmlnn"; if ($ENV{'QUERY_STRING'}) { &do_subroutine; } else { &do_main_subroutine; } sub do_subroutine { print "Hello World.n"; print "The query string is "$ENV{'QUERY_STRING'}"n"; } sub do_main_subroutine { print "Hello World.n"; print "No query string. Do somethin else.n"; } |
|
#6
|
|||
|
|||
|
That seems to work...Thanks, instead of trying to figure out why the first two didn't work I'm just using
####### $input= $ENV{'QUERY_STRING'}; [This message has been edited by jltumlinson (edited July 09, 2000).] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > How do I do this? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|