my $str = "Line 1 has text, but next is an empty line:\r\n\r\nThird line has text\r\n"; print "Original String:\n'$str'\n\n"; print "Ovid:\n", Ovid_Clear_MakePtag($str), "\n\n"; print "mandog:\n", MakePtag($str), "\n"; sub Ovid_Clear_MakePtag{ my $fixme = shift; # take in our parameters return join "\r\n", # join with newlines map { "
$_
" } # wrap each line in tags grep { /\S/ } # must have at least one non-whitespace character split "\r\n", $fixme; # break apart on the newlines } sub MakePtag{ chomp(my $fixme = shift); # take in our parameters $fixme=~s|(\r\n)||g; # replace all \r\n with <\p>
$fixme = "
$fixme
"; # Add beginning and ending tags return $fixme; }