#!/usr/bin/perl -w use strict; open (INPUT, "result.txt") or die "cannot open out\n"; while () { chomp $_; my $first_name = $_; while () { chomp $_; my $next_name = $_; print OUTPUT "$first_name\t$next_name\n"; } }