in reply to Re: Re: Re: Grabbing part of an HTML page
in thread Grabbing part of an HTML page

Well, the current value of $/ has nothing to do with whether or not "." in a regex will match "\n" in a given string value; only the "s" modifier on the regex will allow "." to match "\n", no matter what $/ is. Try this out:
#!/usr/bin/perl $/ = undef; $_ = <DATA>; while ( /begin(.*?)end/g ) { print "\n--- found without 's': ---\n$1\n"; } while ( /begin(.*?)end/gs ) { print "\n--- found using 's': ---\n$1\n"; } __DATA__ blah begin foo bar baz end begin foo2 bar2 baz2 end

Replies are listed 'Best First'.
Re: ^4 Perl Monks - what am I doing wrong?
by cLive ;-) (Prior) on Mar 29, 2004 at 06:05 UTC
    D'oh - I just checked the file I tested on and it doeasn't contain a single new line.

    No wonder I was confused.

    cLive ;-)