in reply to help with conditional match?
my $first_pattern = 'DESCRIPTION:***Private-from-iPhone***'; my $found = 0; while (<>) { chomp; $found = 1 if m/\Q$first_pattern/; if ($found && m/SUMMARY:/) { ... } }
That works, with one caveat - the variable $found will not be reset when the while (<>) { ... } jumps from one file to the next.
You can fix that with a neat trick described in the eof documentation:
... while (<>) { $found = 0 if eof; ... } ...
|
|---|