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

testing the start of a string..

Expand Messages
  • Franki
    Hi again all.. I have another small question, if I have a variable,, say: $myVar= a:bigLongString and I want to test for the presense of a:big at the start of
    Message 1 of 7 , Jul 1, 2001
    • 0 Attachment
      Hi again all..

      I have another small question,

      if I have a variable,, say: $myVar="a:bigLongString"

      and I want to test for the presense of a:big at the start of it.. (and it
      must allow for either upper or lower case)

      what would be the easiest way of doing that?
      should I use split to take off the chars 0 though 4 and use an if/or
      statement to compare it to a:big or A:BIG ?

      what happens then if its mixed case? how can I tell it to ignore case
      altogether?

      also, if I want to test for the presence of String and remove it if its
      there, do I use the same method?

      I am trying to find a relivent section in my perl books, but I have read 40
      pages so far and haven't found anything relivent..

      and there is probably two dozen people in this list who could answer off the
      top of their head...

      any response would be kindly appreciated..

      regards

      Frank






      -----Original Message-----
      From: Franki [mailto:frankieh@...]
      Sent: Sunday, 1 July 2001 11:33 PM
      To: perl-beginner@yahoogroups.com
      Subject: [PBML] Some questions about stuff..



      Hi everyone...

      I am sorry to be a bother, but I have a couple of questions I would like to
      here your word on...


      1. I have to encryption modules that we use for generating a checksum to
      make sure that what is sent in a form post is what gets received at the
      other end..
      We need to give away this script to lots of people, and the checksum modules
      will be useless if everyone knows how it is done.. So I am wondering if its
      possible to use compiled binaries for the modules and access them from a
      standard perl script?? also, we need to do it for both the unix version of
      the script and also the windows version...

      or is there some other way to protect the source of the modules??? (they are
      called directly by the script, not installed in the perl modules
      directories..)

      2. URL strings not working if there are spaces.... like so:
      &SHIPMETHOD=Ground%20Shipping

      This works ok in the unix version of the script, but the win32 one stops
      dead at &SHIPMETHOD=Ground (ie it stops on the first space and all following
      pairs are ignored... so the script fails,

      The only stuff that is changed between the two versions is the path to lib
      statements, and stuff like that, the actual code is the same.

      3. I am wondering if it is safe to use $ENV{'PATH_TRANSLATED'} to initially
      set the value of my $PaTh variable for my NT/2000 version of my scipt..
      (after stripping of the pl file at the end of the string that
      $ENV{'PATH_TRANSLATED'} produces..

      is it safe to do this? I was thinking of using it when the script is first
      run, and then the script asks if the path is correct and if so writes it
      permanently to file so that $ENV{'PATH_TRANSLATED'} need never be used
      again...



      Any help suggestions, critism, general comments, anything,,, would be most
      appreciated...




      kindest regards

      Frank







      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Franki
      Hi all, This list is unusually quiet tonight... but I ll ask anyway in case an expert is on hand to offer advice.. I have this loop: foreach $tag ( sort ( keys
      Message 2 of 7 , Jul 1, 2001
      • 0 Attachment
        Hi all,

        This list is unusually quiet tonight... but I'll ask anyway in case an
        expert is on hand to offer advice..

        I have this loop:

        foreach $tag ( sort ( keys %form ) )
        {

        $redirect .= "&" . $tag . "=" . $form{ $tag };
        }

        # Now re-direct the browser
        print "Location: $redirect\n\n";

        Basically, it is creating a post url with all the keypairs in it..

        I need to add a line or two to it, to check the values, and if they contain
        any spaces.. to swap the spaces to something like
        %20 so that the spaces don't cause everything after the first one to be
        ignored and not added to the url...

        Think I am alittle over my head here, I am still new to this....


        any help would be most appreciated.

        Kindest regards


        Frank
      • Charles K. Clarkson
        ... Take a look at perlfaq4: How can I split a [character] delimited string except when inside [character]? (Comma-separated files) HTH,
        Message 3 of 7 , Jul 1, 2001
        • 0 Attachment
          <sbasak@...>

          : Hi,
          :
          : I want to perform a simple split operation, but can't
          : get the regular expr working. Can anybody help me on
          : this?
          :
          : my $line from a file read is:
          : xyz abc 12sd "pqr stz" dfg (delimited by blank char).
          : I'm doing
          : my ($par1, $par2, $par3, $par4, $par5) = split(/ /, $line);
          : and I'm getting
          : $par4 = "pqr
          : $par5 = stz", which I don't want.
          :
          : I want $par4 = "pqr stz", & $par5 = dfg
          :

          Take a look at perlfaq4:
          'How can I split a [character] delimited string except
          when inside [character]? (Comma-separated files)'

          HTH,
          Charles K. Clarkson
          Clarkson Energy Homes, Inc.
        • Franki
          Hi all,, Just wanted to say thankyou to all of you for helping out,, I have learned heaps from this list over the last year... regex and learning the
          Message 4 of 7 , Jul 1, 2001
          • 0 Attachment
            Hi all,,

            Just wanted to say thankyou to all of you for helping out,, I have learned
            heaps from this list over the last year...

            regex and learning the availability and use of various modules are the two
            biggies I have still to learn properly...
            (how do you guys know what modules to use for what? I always get quick
            answers from this list with regard to modules,, so I am wondering where you
            get your info,, It can't be CPAN as the layout of that site is not conducive
            to quick searches...



            Thanks heaps, its all working together nicely now...

            one question I still have though..

            In a NT/2000 server enviroment, I hate the fact that you can't require files
            in different directories without specifying the path explicly ... ie
            $paTh="c:/inetpub/scripts/";

            in linux/unix which is what I usually right for, you can use stuff like
            ./../somefile.pl in a require statement and it works just great... NT
            doesn't like it at all and prints lots of lovely error messages to tell you
            so...


            So, my last question is this,,

            if I do something like this:

            my $PaTh="$ENV{'PATH_TRANSLATED'}";

            that path would translate to something like "c:/inetpub/scripts/testfile.pl"

            now if I used regex to remove the testfile.pl (or whatever file is after the
            last /)

            is it safe to use that resulting path as the path to require the other libs?
            (with the relivent modifications to point to parent or child directories off
            it??

            is the $ENV{'PATH_TRANSLATED'} something that could be compromised and cause
            the script to be insecure??

            will it work with use strict or taint mode??

            I want to give the windows users of this script, the same ease of install
            that the linux one enjoys,, rather then have them have to work out what the
            server path is and add a path statement to that effect at all of the script
            files...


            has anyone ever done anything like that?


            kindest regards and thanks again..


            Frank
          • Joe Lunsford
            I would appreciate it if someone could tell me how to unsubscribe to this group. Joe __________________________________________________ Do You Yahoo!? Get
            Message 5 of 7 , Jul 3, 2001
            • 0 Attachment
              I would appreciate it if someone could tell me how to unsubscribe to this
              group.

              Joe

              __________________________________________________
              Do You Yahoo!?
              Get personalized email addresses from Yahoo! Mail
              http://personal.mail.yahoo.com/
            Your message has been successfully submitted and would be delivered to recipients shortly.