Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Why multiline regex doesn't work?

by jeffa (Bishop)
on Jun 09, 2015 at 00:40 UTC ( [id://1129580]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Why multiline regex doesn't work?
in thread Why multiline regex doesn't work?

You really should try to work with simpler examples before you make things complicated:

use strict; use warnings; use Data::Dumper; my ($str,@match); $str = " foo bar baz "; @match = $str =~ /(foo.*bar)/; # nope! print Dumper \@match; @match = $str =~ /(foo.*bar)/m; # nope! print Dumper \@match; @match = $str =~ /(foo.*bar)/s; # this one! print Dumper \@match; $str = " foo bar foo baz "; @match = $str =~ /^(foo bar)/; # nope! print Dumper \@match; @match = $str =~ /^(foo bar)/s; # nope! print Dumper \@match; @match = $str =~ /^(foo bar)/m; # this one! print Dumper \@match;

The first set of matches illustrates a case when the 's' modifier gets the match and the second set of matches illustrates a case when the 'm' modifier gets the match. Hope this helps!

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1129580]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-26 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found