[plug] Perl regex question

Daniel Pittman daniel at rimspace.net
Mon Oct 27 19:30:13 WST 2008


Mark O'Shea <mark at musicalstoat.co.uk> writes:
> On Mon, Oct 27, 2008 at 02:34:46PM +1100, Daniel Pittman wrote:
>> > $line =~ s/<script.*script>//smi ;
>> 
>> This like makes *absolutely* no sense: you told Perl; the flags
>> following the regular expression are 'smi', which means:
>> 
>>   s => treat this as a single line
>>   m => treat this as multiple lines
>>   i => ignore case
>> 
>> You might get more sensible behaviour if you specify *one* of those two
>> mutually incompatible options.  In your case, you want '/s', which is an
>> instruction to treat it as a single line.
>
> No, they are not in any way mutually incomaptible (although they are
> often used in a fashion which is).  The exact meaning are:
> /s      Let . match newline and ignore deprecated $* variable.
> /m      Let ^ and $ match next to embedded \n.

I stand corrected: apparently I have missed that for years, including
when I checked the documentation before posting this.  Oh, well.
I appreciate your letting me know.

Regards,
        Daniel



More information about the plug mailing list