in reply to multi line matching problem

$data =~ y/\n/ /; # This will remove all newlines and replace them wit +h spaces
Better still, if you want to replace all the greater than one space(s) in your regular expression and take care of any newlines that you have at the time, you can do so with this RegEx:
$data =~ s/\s+|\n/ /g;
The main key here is that \s* has been replaced with \s+, so it's no longer greedy and will replace only multiple space characters.

The difference between s and m is that s is used to substitue an expression, whilst m is used to test for a pattern match. M is not really used too much as it is implied when you place a regular expression between two slashes (ie. $data =~ /\n/g is the same as $data=~ m/\n/g). The y modifier is a simple character replacement (transliteration).

Update: With much thanks to Enlil for the explaination, the whole regex could actually be written without the \n (i.e. $data =~ s/\s+/ /g).