use strict; use warnings; use IO::File; my $filename = shift @ARGV; my $fh = IO::File->new($filename, 'r'); sub fh_iterator { my $fh = shift; my $line = $fh->getline(); if (defined $line) { $line .= $fh->getline() while $line =~ m{\\$}; } return $line; } while (my $line = fh_iterator($fh)) { print $line; }