$/ = "\0\0"; while (<>) { chomp; if ( m{ \A MSrc .{16} (.+) \z }xms ) { # message in $1 } }