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

Pattern Matching

Expand Messages
  • vallinis@yahoo.com
    Hallo, I am a beginner... I have this line in a loop: $string[$i]=~s/^../$signs{$1}/gi; It should do the following: 1)grabbing, for each entry, the first 2
    Message 1 of 1 , May 4, 2001
    • 0 Attachment
      Hallo,

      I am a beginner...
      I have this line in a loop:

      $string[$i]=~s/^../$signs{$1}/gi;

      It should do the following:
      1)grabbing, for each entry, the first 2 carachters
      2)replace them with the value of their key

      The hash is as follows:
      my %signs=(
      "+"=>' ',
      "20"=>' '
      );

      As you can imagine, is just an attempt to replace the unescaped (such
      as %20)chars in a query_string. So if a string (once stripped the %
      signs )would start:
      20hallo
      should be:
      hallo (with a leading white-space)

      Obviously, it doesn't work. Any idea why?

      I'd also be interested to know what the pack() method does and how it
      works. I noticed some scripts use pack("C",hex($1)) to replace a
      pattern match but I refuse to use it unless I have understood why it
      works you see... the list of the TEMPLATES is far from being obvious
      to my eyes...
      The hex() method appears slightly more obvious to my eyes, but not
      too much.
      Please be patient and keep in mind you're dealing with a beginner!

      Alberto .ยท. Vallini
      vallinis@... - vallini@...
      "Every soul which has acquired any truth, should be safe from harm
      until another period." [R.W.Emerson]
    Your message has been successfully submitted and would be delivered to recipients shortly.