in reply to Null scalars in array
is what you want to search for, I assume.foo a b cd efg bar
The regular expression you mention expects "foo" and "bar" to occur more than once, so it might not be the regexp you are looking for. You could use two steps: first, find everything between "foo" and "bar", then split that into separate words or numbers. The code would then be:
my @matches; if ($data =~ m/foo (.*) bar/) { # everything between foo and bar go +es into $1 @matches = split(' ', $1); # split on whitespace }
I cannot think of a regexp that does it in one go, so I welcome smarter solutions.
|
|---|