/m changes the effect of ^ and $ to match at the start and end of lines (rather than the whole string). You need /s which changes the meaning of . so it matches \n.
I remember it as /s changes the meaning of a single metacharacter and /m changes the meaning of multiple metacharacters.
#!/usr/bin/perl -w use strict; $_ = '<P> THE GENERAL SYNOPSIS AT 0100<BR> LOW SOUTH FITZROY 1000 MOVING SLOWLY NORTH AND FILLING 1006 BY 0100<BR +> TOMORROW. NEW LOW EXPECTED 50 MILES WEST OF TRAFALGAR 1007 BY SAME<BR> TIME. HIGH 100 MILES WEST OF ROCKALL 1023 SLOW MOVING AND DECLINING<BR +> 1021 BY THAT TIME<BR> <P> THE AREA FORECASTS FOR THE NEXT 24 HOURS<BR>'; /GENERAL SYNOPSIS AT (\d{4})<BR>\s+(.*)\s<P>/s; print "1 -> $1\n2 -> $2\n";
Of course the usual caveats about not parsing HTML with regexes still apply :)
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Multi-Line Regex's
by davorg
in thread Multi-Line Regex's
by sch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |