while (<>) { # read line while (s/\\$/ /) { # while the current line ends with \ # replace it by blank and append a new line. chomp; # thanks to ww $_.= <>; }