Hi, merry Xmas, This RE doesn't do what I expected:
#!perl -w $_ = 'data 1 data 2 data 3 head 1 head 2 head 3'; my $a = /^dat.*\n #match 1st line (?s) #turn on . matching any char (.*?3)/x; #should match data 2 and 3 print 'result: ',$a,', $1=',$1||'no match',"\n"; 1; __END__ result: 1, $1=head 3 I thought that '^dat.*\n' would match only the 1st line 'data 1', because '.' doesn't match a new line. Then '(?s)' should make '.' match any char, including new line. Then '(.*?3)' should match lines 'data 2' and 'data 3'. It's not what happens. Anyone can explain ? If the 1st part of the RE is ^dat.*?\n, then: result: 1, $1=data 2 data 3 Why do we have to make it ungreedy ? Thanks. MacPerl 5.20r4