
perlkid
stranger
Mar 2, 2000, 2:10 AM
Post #2 of 7
(749 views)
|
I’m working on a process similar to this. I am putting an extension on the urls like so; <a href ="http://www.yoursite.com/cgi-bin/yourscripts.cgi?step=step2"> You could do this with links and with forms. And in the perl you could do this, but I hope some one will tell you the easier way via a module, but I forgot what to do so I use this. <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> sub parse_form { my (@pairs, %in); my ($buffer, $pair, $name, $value); if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { &cgierr('You cant run this script from telnet/shell.'); } PAIR: foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($value eq "---") and next PAIR; exists $in{$name} ? ($in{$name} .= "~~$value") : ($in{$name} = $value); } return %in; } </pre><HR></BLOCKQUOTE> put that at the bottom of your script and at the top put this %in = &parse_form; Then you could put step two in a sub called step two. sub step_two { print <<ENDHTML; html ENDHTML } you could have code or html, whatever you need. And towards the top of the program put if ($in{'step'} eq "step2") { &step_two; } and same with step 3 and so on. This will execute step two if the url’s extension (step) is equal to step2. I hope that will work for you but If any one knows how to read the url using that module I think Jumaru would be better off. perlkid
|