http://www.perlmonks.org?node_id=25393


in reply to Writing in reverse

Here is another way to do it using chop.
#!/usr/bin/perl -w use IO::File; my $fh1 = new IO::File; my $fh2 = new IO::File; $fh1->open("< file1.txt") or die "can't open file1.txt $!"; $fh2->open("< file2.txt") or die "can't open file2.txt $!"; my $file1 = <$fh1>; my $file2 = <$fh2>; print "Merging:\n"; print "\t$file1\n"; print "\t$file2\n"; while(length $file1){ my $couplet = chop($file1).chop($file2); print "$couplet "; }