Loading ...
Sorry, an error occurred while loading the content.

First Post (pls be gentle), a case of case sensitivity...

Expand Messages
  • cmw_webmaster
    CGI pals and palettes (?), I need to change the Perl code in this section of a script I inherited case insensitive, rather than its current case sensitive
    Message 1 of 11 , Aug 23, 2002
    • 0 Attachment
      CGI pals and palettes (?),

      I need to change the Perl code in this section of a script I
      inherited case insensitive, rather than its current case sensitive
      status. I have reviewed several of the items in the archive on this
      issue and have tried using the 'i' identifier in several places, but
      alas, to no avail. Please help.

      In gratitude, Paul

      #####################################################################
      #
      # Parse input
      #
      #####################################################################
      sub ReadParse {
      local (*in) = @_ if @_; local ($i, $loc, $key, $val);
      if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'};}
      elsif ($ENV{'REQUEST_METHOD'} eq "POST")
      {read(STDIN,$in,$ENV{'CONTENT_LENGTH'});}
      @in = split(/&/,$in);
      foreach $i (0 .. $#in) {
      $in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2);
      $key =~ s/%(..)/pack("c",hex($1))/ge;
      $val =~ s/%(..)/pack("c",hex($1))/ge;
      $in{$key} .= "\0" if (defined($in{$key}));
      $in{$key} .= $val;
      }
      return 1;
      }
    • Charles K. Clarkson
      ... Er, precisely what is your question? What is it doing now that you want changed? Give us an example. HTH, Charles K. Clarkson -- Head Bottle Washer,
      Message 2 of 11 , Aug 23, 2002
      • 0 Attachment
        cmw_webmaster [mailto:cmw_webmaster@...] wrote:

        : CGI pals and palettes (?),
        :
        : I need to change the Perl code in this section of a
        : script I inherited case insensitive, rather than its
        : current case sensitive status. I have reviewed
        : several of the items in the archive on this issue
        : and have tried using the 'i' identifier in several
        : places, but alas, to no avail. Please help.

        Er, precisely what is your question?
        What is it doing now that you want changed?
        Give us an example.


        HTH,

        Charles K. Clarkson
        --
        Head Bottle Washer,
        Clarkson Energy Homes, Inc.
        Small commercial and residential rehabilitation specialists.
        254 968-8328

        CJ Web Work - Solutions for Real Estate Investors.
        972 216-4952

        CJ Web Hosting Lookout - We have one whole paying customer!
        254 968-8328
      • Franki
        that looks alot like one of the subs in the old perl cgi-lib.pl library.. Thats antique nowdays, thanks to someone on this list ages ago, I took it out of all
        Message 3 of 11 , Aug 24, 2002
        • 0 Attachment
          that looks alot like one of the subs in the old perl cgi-lib.pl library..

          Thats antique nowdays, thanks to someone on this list ages ago, I took it
          out of all the scripts I work with. never looked back.

          you might as well do away with that and use the CGI module.

          it even has a cgi-lib compat mode to save you some effort.

          looks like this:

          # Parse the form data
          use CGI;
          CGI::ReadParse(*form);


          assuming %form is the hash you want your keys=>values in.

          thats it,,, you can then delete cgi-lib completely and go for it..

          I'd try that first before you start messing with cgi-lib...

          but on that note, you have not shown us what it does that you don't like
          anyway.
          are you saying that you want query string data to be case insensitive???

          rgds

          Frank




          -----Original Message-----
          From: cmw_webmaster [mailto:cmw_webmaster@...]
          Sent: Saturday, 24 August 2002 5:05 AM
          To: perl-beginner@yahoogroups.com
          Subject: [PBML] First Post (pls be gentle), a case of case
          sensitivity...


          CGI pals and palettes (?),

          I need to change the Perl code in this section of a script I
          inherited case insensitive, rather than its current case sensitive
          status. I have reviewed several of the items in the archive on this
          issue and have tried using the 'i' identifier in several places, but
          alas, to no avail. Please help.

          In gratitude, Paul

          #####################################################################
          #
          # Parse input
          #
          #####################################################################
          sub ReadParse {
          local (*in) = @_ if @_; local ($i, $loc, $key, $val);
          if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'};}
          elsif ($ENV{'REQUEST_METHOD'} eq "POST")
          {read(STDIN,$in,$ENV{'CONTENT_LENGTH'});}
          @in = split(/&/,$in);
          foreach $i (0 .. $#in) {
          $in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2);
          $key =~ s/%(..)/pack("c",hex($1))/ge;
          $val =~ s/%(..)/pack("c",hex($1))/ge;
          $in{$key} .= "\0" if (defined($in{$key}));
          $in{$key} .= $val;
          }
          return 1;
          }



          Unsubscribing info is here:
          http://help.yahoo.com/help/us/groups/groups-32.html

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        • cmw_webmaster
          Thanks, Charles and Franki, for your replies. Right now, the script, when searching for a city named Lodi in the database, will come back with 8 matches, but
          Message 4 of 11 , Aug 24, 2002
          • 0 Attachment
            Thanks, Charles and Franki, for your replies.

            Right now, the script, when searching for a city named Lodi in the
            database, will come back with 8 matches, but when the search tool
            looks for lodi or LODI or LoDi, it comes back with zero matches. I
            would like all inputs of whatever case to come back with 8 matches,
            ergo case-insensitivity.

            I can put up the other Perl apps on this group if you might find it
            helpful. They were authored by Matt Kruse. I am really not clear
            what you all mean about installing new modules, so I am leery about
            going in that direction.

            Thanks again for the help.

            Paul

            --- In perl-beginner@y..., "Franki" <frankieh@i...> wrote:
            > that looks alot like one of the subs in the old perl cgi-lib.pl
            library..
            >
            > Thats antique nowdays, thanks to someone on this list ages ago, I
            took it
            > out of all the scripts I work with. never looked back.
            >
            > you might as well do away with that and use the CGI module.
            >
            > it even has a cgi-lib compat mode to save you some effort.
            >
            > looks like this:
            >
            > # Parse the form data
            > use CGI;
            > CGI::ReadParse(*form);
            >
            >
            > assuming %form is the hash you want your keys=>values in.
            >
            > thats it,,, you can then delete cgi-lib completely and go for it..
            >
            > I'd try that first before you start messing with cgi-lib...
            >
            > but on that note, you have not shown us what it does that you don't
            like
            > anyway.
            > are you saying that you want query string data to be case
            insensitive???
            >
            > rgds
            >
            > Frank
            >
            >
            >
            >
            > -----Original Message-----
            > From: cmw_webmaster [mailto:cmw_webmaster@y...]
            > Sent: Saturday, 24 August 2002 5:05 AM
            > To: perl-beginner@y...
            > Subject: [PBML] First Post (pls be gentle), a case of case
            > sensitivity...
            >
            >
            > CGI pals and palettes (?),
            >
            > I need to change the Perl code in this section of a script I
            > inherited case insensitive, rather than its current case sensitive
            > status. I have reviewed several of the items in the archive on this
            > issue and have tried using the 'i' identifier in several places, but
            > alas, to no avail. Please help.
            >
            > In gratitude, Paul
            >
            >
            #####################################################################
            > #
            > # Parse input
            > #
            >
            #####################################################################
            > sub ReadParse {
            > local (*in) = @_ if @_; local ($i, $loc, $key, $val);
            > if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'};}
            > elsif ($ENV{'REQUEST_METHOD'} eq "POST")
            > {read(STDIN,$in,$ENV{'CONTENT_LENGTH'});}
            > @in = split(/&/,$in);
            > foreach $i (0 .. $#in) {
            > $in[$i] =~ s/\+/ /g; ($key, $val) = split(/=/,$in[$i],2);
            > $key =~ s/%(..)/pack("c",hex($1))/ge;
            > $val =~ s/%(..)/pack("c",hex($1))/ge;
            > $in{$key} .= "\0" if (defined($in{$key}));
            > $in{$key} .= $val;
            > }
            > return 1;
            > }
            >
            >
            >
            > Unsubscribing info is here:
            > http://help.yahoo.com/help/us/groups/groups-32.html
            >
            > Your use of Yahoo! Groups is subject to
            http://docs.yahoo.com/info/terms/
          • Charles K. Clarkson
            ... Then the problem is in the database lookup, not the form parser. I assume you have a field on the form called city and you access it with $in{ city } .
            Message 5 of 11 , Aug 24, 2002
            • 0 Attachment
              cmw_webmaster [mailto:cmw_webmaster@...] wrote:

              : Thanks, Charles and Franki, for your replies.
              :
              : Right now, the script, when searching for a city
              : named Lodi in the database, will come back with 8
              : matches, but when the search tool looks for lodi
              : or LODI or LoDi, it comes back with zero matches.
              : I would like all inputs of whatever case to come
              : back with 8 matches, ergo case-insensitivity.

              Then the problem is in the database lookup, not
              the form parser. I assume you have a field on the form
              called 'city' and you access it with '$in{ city }'.

              Assuming you have:

              print db_city_lookup( $in{ city } );

              sub db_city_lookup {
              # needs: Title Cased Cities
              }

              Try:

              print db_city_lookup( ucfirst( lc( $in{ city } ) ) );

              sub db_city_lookup {
              # needs: Title Cased Cities
              }

              This still won't work on cities with more than
              one word like: 'New Orleans'. Your best bet is to
              modify the algorithm that is doing the lookup. We
              can help you with that, but you'll have to show
              the code for it.

              : I can put up the other Perl apps on this group if
              : you might find it helpful. They were authored by
              : Matt Kruse. I am really not clear what you all
              : mean about installing new modules, so I am leery
              : about going in that direction.

              Step toward the light Paul!

              CGI.pm is THE standard for modern perl CGI
              programming. Rolling your own ReadParse sub is good
              for learning, but will fail when you least expect it.
              CGI.pm has had hundreds of thousands of hours of
              testing and tweaking by some of the finest perl
              programmers. Mr. Kruse does not seem to be the
              person to learn good modern CGI programming habits
              from.

              HTH,

              Charles K. Clarkson
              --
              Head Bottle Washer,
              Clarkson Energy Homes, Inc.
              Small commercial and residential rehabilitation specialists.
              254 968-8328

              CJ Web Work - Solutions for Real Estate Investors.
              972 216-4952

              CJ Web Hosting Lookout - We have one whole paying customer!
              254 968-8328
            • Franki
              also, you probably don t have to install CGI.pm chances are you already have it installed. rgds Franki. PS, Charles and the others are right, once you get over
              Message 6 of 11 , Aug 24, 2002
              • 0 Attachment
                also, you probably don't have to install CGI.pm

                chances are you already have it installed.

                rgds

                Franki.


                PS, Charles and the others are right, once you get over the newbie aversion
                to modules and oop and start learning them, your perl world really starts to
                open up.

                This newbie (me) only just discovered that myself..

                -----Original Message-----
                From: Charles K. Clarkson [mailto:cclarkson@...]
                Sent: Saturday, 24 August 2002 11:21 PM
                To: perl-beginner@yahoogroups.com
                Subject: RE: [PBML] First Post (pls be gentle), a case of case
                sensitivity...


                cmw_webmaster [mailto:cmw_webmaster@...] wrote:

                : Thanks, Charles and Franki, for your replies.
                :
                : Right now, the script, when searching for a city
                : named Lodi in the database, will come back with 8
                : matches, but when the search tool looks for lodi
                : or LODI or LoDi, it comes back with zero matches.
                : I would like all inputs of whatever case to come
                : back with 8 matches, ergo case-insensitivity.

                Then the problem is in the database lookup, not
                the form parser. I assume you have a field on the form
                called 'city' and you access it with '$in{ city }'.

                Assuming you have:

                print db_city_lookup( $in{ city } );

                sub db_city_lookup {
                # needs: Title Cased Cities
                }

                Try:

                print db_city_lookup( ucfirst( lc( $in{ city } ) ) );

                sub db_city_lookup {
                # needs: Title Cased Cities
                }

                This still won't work on cities with more than
                one word like: 'New Orleans'. Your best bet is to
                modify the algorithm that is doing the lookup. We
                can help you with that, but you'll have to show
                the code for it.

                : I can put up the other Perl apps on this group if
                : you might find it helpful. They were authored by
                : Matt Kruse. I am really not clear what you all
                : mean about installing new modules, so I am leery
                : about going in that direction.

                Step toward the light Paul!

                CGI.pm is THE standard for modern perl CGI
                programming. Rolling your own ReadParse sub is good
                for learning, but will fail when you least expect it.
                CGI.pm has had hundreds of thousands of hours of
                testing and tweaking by some of the finest perl
                programmers. Mr. Kruse does not seem to be the
                person to learn good modern CGI programming habits
                from.

                HTH,

                Charles K. Clarkson
                --
                Head Bottle Washer,
                Clarkson Energy Homes, Inc.
                Small commercial and residential rehabilitation specialists.
                254 968-8328

                CJ Web Work - Solutions for Real Estate Investors.
                972 216-4952

                CJ Web Hosting Lookout - We have one whole paying customer!
                254 968-8328








                Unsubscribing info is here:
                http://help.yahoo.com/help/us/groups/groups-32.html

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
              • cmw_webmaster
                ... Ok, I uploaded the three main .pl files into a directory on this group. Go to: http://groups.yahoo.com/group/perl-beginner/files/Paul%27s%20Problem/ Just
                Message 7 of 11 , Aug 25, 2002
                • 0 Attachment
                  >
                  > Then the problem is in the database lookup, not
                  > the form parser. I assume you have a field on the form
                  > called 'city' and you access it with '$in{ city }'.
                  >
                  > Assuming you have:
                  >
                  > print db_city_lookup( $in{ city } );
                  >
                  > sub db_city_lookup {
                  > # needs: Title Cased Cities
                  > }
                  >
                  > Try:
                  >
                  > print db_city_lookup( ucfirst( lc( $in{ city } ) ) );
                  >
                  > sub db_city_lookup {
                  > # needs: Title Cased Cities
                  > }
                  >
                  > This still won't work on cities with more than
                  > one word like: 'New Orleans'. Your best bet is to
                  > modify the algorithm that is doing the lookup. We
                  > can help you with that, but you'll have to show
                  > the code for it.
                  >

                  Ok, I uploaded the three main .pl files into a directory on this
                  group. Go to:

                  http://groups.yahoo.com/group/perl-beginner/files/Paul%27s%20Problem/

                  Just so you know, the data file that I have not included is a pipe
                  ("|") delimited file for the fields it contains.

                  This is very helpful and I greatly appreciate your assistance!

                  > Step toward the light Paul!
                  >
                  > CGI.pm is THE standard for modern perl CGI
                  > programming. Rolling your own ReadParse sub is good
                  > for learning, but will fail when you least expect it.
                  > CGI.pm has had hundreds of thousands of hours of
                  > testing and tweaking by some of the finest perl
                  > programmers. Mr. Kruse does not seem to be the
                  > person to learn good modern CGI programming habits
                  > from.

                  Charles and Franki, while I appreciate your statement about "getting
                  with the program", so to speak (heck, I even found myself laughing at
                  myself), I am responsible with just maintaining this site and only
                  have three requested modifications to make, hardly justifying the
                  effort at this juncture of learning a new way of doing this code.
                  Having said that, know that I will send an email to the web hosting
                  firm and figure out whether CGI.pm is installed or not.

                  Much thanks!

                  Paul
                • Charles K. Clarkson
                  cmw_webmaster [mailto:cmw_webmaster@yahoo.com] ... No problem. How many fields are in the data file. Can you post a dummy file? ... When you re working for a
                  Message 8 of 11 , Aug 25, 2002
                  • 0 Attachment
                    cmw_webmaster [mailto:cmw_webmaster@...]

                    : Just so you know, the data file that I have not included is a pipe
                    : ("|") delimited file for the fields it contains.
                    :
                    : This is very helpful and I greatly appreciate your assistance!

                    No problem. How many fields are in the data file.
                    Can you post a dummy file?

                    : Charles and Franki, while I appreciate your statement about "getting
                    : with the program", so to speak (heck, I even found myself laughing at
                    : myself), I am responsible with just maintaining this site and only
                    : have three requested modifications to make, hardly justifying the
                    : effort at this juncture of learning a new way of doing this code.
                    : Having said that, know that I will send an email to the web hosting
                    : firm and figure out whether CGI.pm is installed or not.

                    When you're working for a client you do what the
                    client wants. This code can be made much more efficient,
                    but you know the clients needs and priorities best.

                    I have a server researcher script I just made for my
                    hosting business. You can download it at:
                    http://cjwebhosting.com/cgi-bin/force_down.pl/download/researcher.pl
                    I've only tested it for our Redhat Linux boxes. Let me
                    know if it runs okay on your box. Don't leave it on
                    the server for security reasons.


                    SOLUTION(?):

                    Look for a piece of code in search.pl that looks like:

                    # user location found in address
                    if (($location ne "") && ($thismatch !=0) ) {
                    if (index($addr,$location) +1 ) {
                    $thismatch = 1;
                    } else {
                    $thismatch = 0;
                    }
                    }

                    Change the second line to:

                    if ( index( lc $addr, lc $location ) + 1 ) {

                    That should look for a lowercase address in a
                    lowercase location. Let the list know if that makes
                    your searches case-insensitive.


                    HTH,

                    Charles K. Clarkson
                    --
                    Head Bottle Washer,
                    Clarkson Energy Homes, Inc.
                    Small commercial and residential rehabilitation specialists.
                    254 968-8328

                    CJ Web Work - Solutions for Real Estate Investors.
                    972 216-4952

                    CJ Web Hosting Lookout - We have one whole paying customer!
                    254 968-8328
                  • cmw_webmaster
                    Charles, Thank you, thank you, a thousand thank yous! It works! I might be back in case the client asks for more. In gratitude, Paul p.s. The web hosting firm
                    Message 9 of 11 , Aug 26, 2002
                    • 0 Attachment
                      Charles,

                      Thank you, thank you, a thousand thank yous! It works!

                      I might be back in case the client asks for more.

                      In gratitude,

                      Paul

                      p.s. The web hosting firm verified that CGI.pm is installed, so, for
                      any new functionality, I will definitely be combing the archives for
                      tips/tricks, then possibly post again to the list if need be.
                    • cmw_webmaster
                      ... for ... for ... Can anyone recommend a good CGI.pm tutorial web site for me to begin learning the -modern, enlightened- way for CGI programming? In
                      Message 10 of 11 , Sep 30, 2002
                      • 0 Attachment
                        --- In perl-beginner@y..., "cmw_webmaster" <cmw_webmaster@y...> wrote:
                        > Charles,
                        >
                        > Thank you, thank you, a thousand thank yous! It works!
                        >
                        > I might be back in case the client asks for more.
                        >
                        > In gratitude,
                        >
                        > Paul
                        >
                        > p.s. The web hosting firm verified that CGI.pm is installed, so,
                        for
                        > any new functionality, I will definitely be combing the archives
                        for
                        > tips/tricks, then possibly post again to the list if need be.

                        Can anyone recommend a good CGI.pm tutorial web site for me to begin
                        learning the -modern, enlightened- way for CGI programming?

                        In gratitude,

                        Paul
                      • Charles K. Clarkson
                        ... Besides the book: Read the Docs: http://stein.cshl.org/WWW/software/CGI/cgi_docs.html Use CGI or Die; http://www.perlmonks.com/index.pl?node=51012 Have a
                        Message 11 of 11 , Sep 30, 2002
                        • 0 Attachment
                          cmw_webmaster [mailto:cmw_webmaster@...] wrote:

                          : Can anyone recommend a good CGI.pm tutorial web site
                          : for me to begin learning the -modern, enlightened-way
                          : for CGI programming?

                          Besides the book:

                          Read the Docs:
                          http://stein.cshl.org/WWW/software/CGI/cgi_docs.html

                          Use CGI or Die;
                          http://www.perlmonks.com/index.pl?node=51012

                          Have a look at Ovid's Course:
                          http://www.easystreet.com/~ovid/cgi_course/index.html

                          I like CGI::Application and HTML::Template:
                          http://www.perl.com/pub/a/2001/06/05/cgi.html


                          HTH,

                          Charles K. Clarkson
                          --
                          Head Bottle Washer,
                          Clarkson Energy Homes, Inc.
                          Small commercial and residential rehabilitation specialists.

                          254 968-8328

                          CJ Web Work - Solutions for Real Estate Investors.
                          972 216-4952

                          CJ Web Hosting - Affordable Hosting - Custom Accounts.
                          254 968-8328
                        Your message has been successfully submitted and would be delivered to recipients shortly.