[Melbourne-pm] Regexp: What's the right way to do this?

Nathan Bailey nathan.bailey at monash.edu
Wed Oct 17 00:09:22 PDT 2012


The code below works, but the commented out bits don't. I presume that when $shh and $smm are defined on the first loop through, they get undefined on the next time through?

What's the "right" way to do this, TIMTOWTDI notwithstanding :-)
N

while(<>) {
      #if (($shh,$smm) = m#^\s*<div class="event-time calendar-\d+">(\d+):(\d+) -#) {
      if (m#^\s*<div class="event-time calendar-\d+">(\d+):(\d+) -#) {
         $shh = $1; $smm = 2;
         $event++;
      #} elsif (($fhh,$fmm) = m#^\s*(\d+):(\d+)</div>#) {
      } elsif (m#^\s*(\d+):(\d+)</div>#) {
         $fhh = $1; $fmm = 2;
         $event++;
      #} elsif (($summary) = m#^\s*<p class="summary">(.*)</p>#) {
      } elsif (m#^\s*<p class="summary">(.*)</p>#) {
         $summary = $1;
         $event++;
      } elsif (($description) = m#^\s*<p class="description">(.*)</p>#) {
         $event++;
      }
}


More information about the Melbourne-pm mailing list