match 3 or more carriage returns... maybe like this? if =~ m/[\n]{3,}/