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

RE: [PBML] Regex - Matching multiple times in a line

Expand Messages
  • Mark Sutfin
    ... m/declare s+.+ s+procedure s+for s+( w+)/i; ... to see if it s 1 or 0. Whoops. If $count is defined (?) then there was a match..I see, very cool! May I (be
    Message 1 of 5 , Feb 23, 2005
    • 0 Attachment
      Randal got Mark's attention :

      >>>>>> "Mark" == Mark Sutfin <msutfin@...> writes:

      >Mark> $count = () = $_ =~
      m/declare\s+.+\s+procedure\s+for\s+(\w+)/i;
      >Mark> if ($1) {

      >This is not good. $1 may retain its value from the previous loop.
      >That's not what you want to test. You want to test the value of $count
      to see if it's 1 or 0.

      Whoops. If $count is defined (?) then there was a match..I see, very
      cool!

      May I (be so bold) as to ask if you happened to see the second part of
      my question...how to match/capture multiple occurrences in a slurped
      file?

      Thanks!
      Mark
    • merlyn@stonehenge.com
      ... Mark May I (be so bold) as to ask if you happened to see the second part of Mark my question...how to match/capture multiple occurrences in a slurped
      Message 2 of 5 , Feb 23, 2005
      • 0 Attachment
        >>>>> "Mark" == Mark Sutfin <msutfin@...> writes:

        Mark> May I (be so bold) as to ask if you happened to see the second part of
        Mark> my question...how to match/capture multiple occurrences in a slurped
        Mark> file?

        while ($bigstring =~ /some pattern with (parens)/g) {
        do something with $1;
        }

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
      Your message has been successfully submitted and would be delivered to recipients shortly.