Re: CGI URLs in HREFs (was Re: An smtp URL scheme)

At 12:07a -0700 07/13/97, Walter Ian Kaye wrote:
 >
 > So, I guess I'll have to update my 'wiklib.pl' library to check for
 > semicolons instead of just assuming ampersands. Now to come up with
 > a good algorithm. How about this:
 >
 >   1. Count number of '='s in query string.
 >   2. If more than one, determine whether '&' or ';' is used as field
 >      separator:
 >
 >      ??? Extract substring from first '=' to second '=', then count
 >          number of '&'s and ';'s, and compare counts. ???
 >
 >   3. Split accordingly.
 >
 > That oughta do it, eh?

Perl code (as yet untested) now looking like this:

   $query =~ s/\r\n$//;                 # delete any trailing CRLF.
   $sep = '&';
   @eqarr = split(/=/,$query);
   $fields = scalar(@eqarr) - 1;
   if ($fields > 1) {
      $eqstr = @eqarr[1];
      $amptot = scalar(split(/&/,$eqstr)) - 1;
      $semtot = scalar(split(/;/,$eqstr)) - 1;
      if ($semtot && $semtot > $amptot) {
         $sep = ';';
         }
      }
   @query = split($sep,$query);

That look ok?

__________________________________________________________________________
  Walter Ian Kaye <boo_at_best*com>    Programmer - Excel, AppleScript,
          Mountain View, CA                         ProTERM, FoxPro, HTML
 http://www.natural-innovations.com/     Musician - Guitarist, Songwriter

Received on Sunday, 13 July 1997 04:27:22 UTC