Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 8th, 2000, 11:48 PM
jltumlinson jltumlinson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Texas, US
Posts: 9 jltumlinson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jltumlinson Send a message via MSN to jltumlinson Send a message via Yahoo to jltumlinson
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!

Reply With Quote
  #2  
Old July 9th, 2000, 01:58 AM
deviant deviant is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 27 deviant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old July 9th, 2000, 03:09 AM
chinnavi
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

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

Reply With Quote
  #4  
Old July 9th, 2000, 01:07 PM
jltumlinson jltumlinson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Texas, US
Posts: 9 jltumlinson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jltumlinson Send a message via MSN to jltumlinson Send a message via Yahoo to jltumlinson
Thanks for the help, but neither method seems to work.

Reply With Quote
  #5  
Old July 9th, 2000, 01:17 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
>>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";
}

Reply With Quote
  #6  
Old July 9th, 2000, 01:42 PM
jltumlinson jltumlinson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Location: Texas, US
Posts: 9 jltumlinson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jltumlinson Send a message via MSN to jltumlinson Send a message via Yahoo to jltumlinson
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).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > How do I do this?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway