while ($line = <>) { while ($line =~ s/\\\n//) { $line .= <>; } # ... do useful stuff with $line here ... }