$_ = do { local $/; <> }; print "Match: $_" for /^\*+$ (.+?) ^\*+$/smxg; #### #!/usr/bin/env perl use 5.012; use warnings; use strict; $_ = do { local $/; }; print "Match: $_" for /^\*+$ (.+?) ^\*+$/smxg; __DATA__ Here's a text file ********************************** You want the stuff in between the asterisks, which is this sentence. ********************************** ********************************** You probably want this too ********************************** But not this ********************************** Or this either #### Match: You want the stuff in between the asterisks, which is this sentence. Match: You probably want this too