#!/bin/perl use strict; open(IN,"file1"); open(IN2,"file2"); open (OUT,"> output"); while (my $str = ) { chomp($str); my $data = ; $data =~ s/(.*?)\s(.*)/$1 $str $2/; print OUT ($data); }