#!/bin/perl open(IN, "file1"); open(IN2, "file2"); open(OUT, "> output"); while ($str = ) { chomp($str); $data = ; chomp($data); @box = split(/\s+/, $data); splice(@box, 1, 0, $str); print OUT (join(' ', @box) . "\n"); }