#!/usr/bin/perl # www-srv(0)# ./lala.pl file1 file2 # pepe,jesus # anto,maria # jose,jose # maria,anto # jesus,pepe # www-srv(0)# cat file1 # 1,pepe # 2,anto # 3,jose # 4,maria # 5,jesus # www-srv(0)# cat file2 # pepe,5 # anto,4 # jose,3 # maria,2 # jesus,1 sub get { open f2, $ARGV[1] or die $!; while(){ return +(split ",", $_)[0] if($_ =~ /,$_[0]$/) }; } open f1, $ARGV[0] or die $!; while(){ chop $_; print +(split ",", $_)[1].",".get(+(split ",", $_)[0])."\n"; } close f1;