Smaug has asked for the wisdom of the Perl Monks concerning the following question:

Hello all knowing PerlMonks,

I'm having a problem which I don't quite understand. I am seaching a string and matching on certain values. Once I find the values (foo xx xx xx bar) I grab the text in between and add it to an array.

I saw some code on perlmonks today which has made my life both easier and more painful. It is:
@matches = $data =~ m/VALUE: (.+?) OID/g;

Perfect for my needs. I just changed it to:
@matches = $data =~ m/foo (.+?) bar/g;

The problem I am having now is that sometimes there is nothing between foo and bar. There should always be 15 values but if I have two instances where there is nothing between foo and bar, @matches only contains 13 values and the first value after the null looks like "foo bar 'next value'"

Is this right? Have I gone mad? (yes) and could somebody help me get around this?