while (<>) { chomp; if (s/\\$//) { $_ .= <>; redo; } # now process $_ }