in reply to Re^4: Improve foreach with help of map?
in thread Improve foreach with help of map?

Use this:
$content =~ /End Date/g and $content =~ /(\d\d \w\w\w \d\d\d\d)/g and +my $result = $1;

Replies are listed 'Best First'.
Re^6: Improve foreach with help of map?
by ikegami (Patriarch) on Oct 09, 2009 at 15:45 UTC
    Nice, although second /g should be omitted
      Perhaps you should actually try your suggestions first. It will not work correctly if you omit the second /g.
      my $content = <<EOT; Blah blah 12 Feb 1992 # Wrong date! Mah Mah Mah End Date: 14 Jul 2007 # Correct date! EOT $content =~ /End Date/g and $content =~ /(\d\d \w\w\w \d\d\d\d)/ and my $result1 = $1; say "Ikegami's end date: $result1"; pos($content) = 0; $content =~ /End Date/g and $content =~ /(\d\d \w\w\w \d\d\d\d)/g and my $result2 = $1; say "JavaFan's end date: $result2"; __END__ Ikegami's end date: 12 Feb 1992 JavaFan's end date: 14 Jul 2007
        Right. My fix was wrong. You need to reset pos some other way on success. Unfortunately, it appears to be simpler to use a single match.