#!/usr/bin/perl use warnings; use strict; my @lines = (); while (<>) { chomp; if (s/\\$//) { my $line = <>; $_.= $line, redo; } push @lines, $_; } foreach (0..$#lines) { print "$_ : $lines[$_] \n"; }