in reply to how to write a multi-line regex

You need to flag that you intend the regex to be multi line with comments using the x modifier. When quoting a regex use the qr operator:
my $regex =qr{ ^(\w*)?\s #A comment (\w*)?\s # an other (\w*)?\s # and again (?:([A-Z]*)\s)? # all the way through (\d+)\* # so that the homicidal psychopath (?:([0-9+]+)[>])? # who knows where you live ([0-9+]+)\s. # and will have to maintain this code (\d*) # will think well of you }x; $input=~$regex
http://http://www.perl.com/doc/manual/html/pod/perlop.html#item_qr for more detail

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."