foreach my $lineb(@FILEB){ my ($NameB, $password, $location)=split(/,/,$lineb); if ( $nameA = $nameB ) { print "$nameA, $machine, $password\n"; }