Hi People

I need to compare a particular line in a file with a particular string in the other file. I am attaching both the files for your reference.
here is my code:

open (INFILE, "$input") or die "Couldn't open $input for reading: $!\n";
  while(<INFILE>)
   {
    my $line= $_;
    $line=~tr/\n//d;
    my($city,$country,$lan,$lat) = (split(/\t/))[0,1,2,3];
    push(@aj1,"$city");
    push(@aj2, "$country");
    push(@aj3,"$lan");
    push(@aj4,"$lat");
   }
   close(INFILE);
 my $arr_size = $#aj1;
open (OUTFILE, ">$output") or die "Couldn't open $output for writing: $!\n";
open (INFILE2, "<$input2") or die "Couldn't open $input2 for reading: $!\n";
   while(<INFILE2>)
   {
    my $lines=$_;
    #$lines=~tr/\n//d;
    print"$lines";
   my($jass,$author,$add) = (split(/\|/,"$lines"))[0,1,2];
   my $j=0;
       for(my $i=0;$i<=$arr_size;$i++)
        {
          my $country1=$aj2[$i];
          my $city1=$aj1[$i];
            if(($add=~m/$country1/) && ($add=~m/$city1/))
             {
             if($j==0)
             {
             #print"$j";
               $j=$j+1;
              print OUTFILE"$lines|";
		      print OUTFILE"$aj1[$i]|";
              print OUTFILE"$aj2[$i]|";
              print OUTFILE"$aj3[$i]|";
              print OUTFILE"$aj4[$i]\n";
            }
           }
      }
           if ($j==0)
           {
              for(my $k=0;$k<=$arr_size;$k++)
        	{
        	 my $countr=$aj2[$k];
            if($add=~m/$countr/ && $j!=1)
             {
               $j=$j+1;
           	  print OUTFILE"$lines|";
		      print OUTFILE"|";
              print OUTFILE"$aj2[$k]|";
              print OUTFILE"0|";
              print OUTFILE"0\n";
           }
         } 
       }
     }   
 close(INFILE2);
 close(OUTFILE);
exit;

Now what I want in the output file is that it should take the first line of the address file , print it like that and wherever it finds the matching city and country from the city_lan.txt file it shud print it afterwards sumwhat like this:
1.1.2|1. Giorgio Brajnik 2. Marji Lines |1. Dipartimento di Matematica e InformaticaUniversit&agrave; di Udine Udine Italy Italy 2. Dipartimento di Scienze StatisticheUniversit&agrave; di Udine Udine Italy 33100 Italy |Udine|Italy|78|87


The problem is when i am printing $lines of input file 2 it is terminating at 2.3.3 and giving an error like this:
Quantifier follows nothing in regex; marked by <-- HERE in m/? <-- HERE stanbul / at "filename" line 39, <INFILE2> line 46, why am i not able to read the whole data .what is the problem..can sumbody help??

Attachments
1.1.1|Dwight Read|Department of AnthropologyUCLA	Los Angeles	CA 90095, USA	United States 
1.1.2|Giorgio Brajnik|Dipartimento di Matematica e InformaticaUniversit&agrave; di Udine	Udine	Italy	Italy 
1.1.2|Marji Lines|Dipartimento di Scienze StatisticheUniversit&agrave; di Udine	Udine	Italy	33100	Italy 
1.1.3|Jim Doran|&quot;Thistles&quot;6-7 Brick Kiln Lane	Great Horkesley	COLCHESTER	CO6 4EU	United Kingdom 
1.1.4|Michael Macy|358 Uris HallIthaca	NY	14853-7601	United States 
1.1.5|Cristiano Castelfranchi|Italy 
1.2.1|Federico Cecconi|ISTCnrVia San Martino della Battaglia 44	Rome	00185	Italy 
1.2.1|Domenico Parisi|Laboratory of Artificial Life and RoboticsInstitute of Cognitive Sciences and Technologies	C.N.R.	44 Via S. Martino della Battaglia - 00185 Rome - Italy	Italy 
1.2.2|Guillemette Duchateau-Nguyen|Equipe de Bioinformatique des GenomesInstitut de Genetique et Microbiologie	Batiment 400 Universite Paris Sud	91405 ORSAY cedex FRANCE	France 
1.2.2|G?rard Weisbuch| 
1.2.3|Jaime Sim&atilde;o Sichman|Intelligent Techniques Laboratory (LTI)Computer Engineering Department (PCS)	University of Sao Paulo (USP)	av. Prof. Luciano Gualberto 158 tv. 3, Sao Paulo SP Brazil	05508-970	Brazil 
1.2.4|Pietro Terna|Dipartimento di Scienze economiche e finanziariecorso Unione Sovietica 218bis	Torino	Italy	10134	Italy 
1.2.5|Fu-ren Lin|Institute of Service ScienceNational Tsing Hua University	101 Sec. Kuangfu Rd.	Hsinchu City	300	Taiwan 
1.2.5|Michael J Shaw|385 Wohlers Hall1206 South Sixth Street	Champaign	IL 61820	United States 
1.2.5|Troy J Strader|College of Business &amp; Public Admin.2507 University Avenue	Des Moines	IA	50311-4505	United States 
1.3.1|Rainer Hegselmann|Institut fuer PhilosophieUniversity of Bayreuth	Universitaetstr. 30	Bayreuth	D- 95440	Germany 
1.3.1|Andreas Flache|ICSUniversity of Groningen	Grote Rozenstraat 31	9712 TG Groningen, The Netherlands	Netherlands 
1.3.2|Edmund Chattoe-Brown|Department of SociologyUniversity of Leicester	University Road	Leicester	LE1 7RH	United Kingdom 
1.3.3|Cristiano Castelfranchi|Italy 
1.3.3|Rosaria Conte|National Research CouncilInstitute of Cognitive Science and Technologies	V. San Martino della Battaglia 44	Roma	00185	Italy 
1.3.3|Mario Paolucci|LABSS (Laboratory on Agent-Based Social Simulation)Institute of Cognitive Science and Technology	CNR	Via San Martino della Battaglia, 44 Rome, Italy	00185	Italy 
1.3.4|Kathleen Carley|1325 Wean Hall5000 Forbes Avenue	Pittsburgh	PA 15213	United States 
1.3.4|Zhiang (John) Lin|School of ManagementSM43	The University of Texas at Dallas	Richardson TX 75083-0688, USA	75083-0688	United States 
1.3.4|Michael J. Prietula|Emory Univesity1300 Clifton Road	Atlanta GA	30322	United States 
1.3.5|Thomas Malsch|Technische Universitaet Hamburg-HarburgInstitut f&uuml;r Technik und Gesellschaft	Schwarzenbergstrasse 95	21071 Hamburg	Germany 
1.3.5|Heinz-J&uuml;rgen M&uuml;ller|Forschungs- und Technologiezentrum (FE14k)Postfach 10 00 03	64276 Darmstadt	Germany	Germany 
1.3.5|Ingo Schulz-Schaeffer|Institute of SociologyLotharstr. 65	Duisburg	47057	Germany 
1.4.1|Scott Moss|BrookfoldThe Wash	Chapel en le Frith	High Peak	SK23 0QW	United Kingdom 
1.4.2|David Hales|Dept. of Computer ScienceUniversity of Bologna	Mura Anteo Zamboni 7	40127 Bologna, Italy	Italy 
1.4.3|Rafael H Bordini|Department of Computer ScienceUniversity of Durham	South Road	Durham	DH1 3LE	United Kingdom 
1.4.3|John A. Campbell|Department of Computer ScienceUniversity College London	Gower Street	London WC1E 6BT, U.K.	WC1E 6BT	United Kingdom 
1.4.3|Renata Vieira|Centre for Social CommunicationPostgraduate Programme in Communication and Semiotics	Universidade do Vale do Rio dos Sinos	CP 275, CEP 93022-000, S&atilde;o Leopoldo, RS, Brazil	Brazil 
2.1.1|Patricia Dorman|Department of SociologyBoise State University	Boise	Idaho 83725USA	United States 
2.1.1|Robert Marsh|Criminal Justice AdministrationBoise State University	Boise	Idaho 83725USA	United States 
2.1.1|Steven Patrick|Department of SociologyBoise State University	Boise	Idaho 83725USA	United States 
2.1.2|Andreas G. Harrer|Professur f&uuml;r InformatikOstenstr. 14	85072 Eichst&auml;tt	Germany 
2.1.2|Nicole J. Saam|Staatswissenschaftiche FakultaetNordhaeuser Str. 63	D-99089 Erfurt	Germany	Germany 
2.1.3|Nigel Gilbert|Department of SociologyFaculty of Arts and Human Sciences	Stag Hill	Guildford	GU2 7XH	United Kingdom 
2.1.4|Rosaria Conte|National Research CouncilInstitute of Cognitive Science and Technologies	V. San Martino della Battaglia 44	Roma	00185	Italy 
2.1.4|Scott Moss|BrookfoldThe Wash	Chapel en le Frith	High Peak	SK23 0QW	United Kingdom 
2.2.1|Jos? Caldas|LisbonPortugal 
2.2.1|Helder Coelho|Faculdade de CienciasBloco C5	Piso 1	Campo Grande, Lisboa, Portugal	1749-016	Portugal 
2.2.2|Wander Jager|Faculty of Economics and BusinessMarketing Institute	PO Box 800	Groningen	9700 AV	Netherlands 
2.2.2|Marco A. Janssen|School of Human Evolution and Social ChangeBox 872402	Tempe	Arizona	85287-2402	United States 
2.2.3|Gerard Ballot|ERMES12 Place du Pantheon	Paris	France	75005	France 
2.2.3|Erol Taymaz|Department of EconomicsMiddle East Technical University	Ankara	Turkey	06531	Turkey 
2.2.4|Elke Mentges|Computer Science Applications in the Social SciencesDepartment of Computer Science	University of Koblenz	Rheinau 1, D-56075 Koblenz, Germany	Germany 
2.3.1|John Kemp|United Kingdom 
2.3.2|Bruce Edmonds|Centre for Policy ModellingManchester Metropolitan University	Aytoun Building	Aytoun Street, United Kingdom	M1 3GH	United Kingdom 
2.3.3|Peter Tucker|Environmental Initiatives GroupHigh Street	PAISLEY	PA1 2BE	United Kingdom 
2.3.3|Andrew Smith|Language Evolution and Computation Research UnitSchool of Philosophy	Psychology and Language Sciences	University of Edinburgh,Adam Ferguson Building, 40 George Square	EH8 9LL	Edinburgh, United Kingdom 
2.3.4|Anne Di Piazza|Universite de ProvenceCampus St Charles	3&uml;Place Victor Hugo	Marseille-France	13331	France 
2.3.4|Erik Pearthree| 
2.3.5|Douglas White|Social Dynamics and ComplexityInstitute for Mathematical Beh. Sciences	School of Social Sciences	Irvine, California	92697	United States 
2.3.6|Cathy Small|Box 15200Dept of Anthropology	Flagstaff	AZ, USA	86001	United States 
2.3.7|J&uuml;rgen Kl&uuml;ver|COBASC- Research GroupFB WiWi (Department of Economics)	University of Duisburg-Essen	Campus Essen	45117 Essen	Germany 
2.3.7|J?rn Schmidt|University of EssenHDZ	Universitaetsstr. 12	45117 Essen, Germany	Germany 
2.3.8|John B. Corliss|Complex Adaptive Systems LaboratoryEnvironmental Sciences and Policy	Central European University	Kerepesi t 87., 1106 Budapest, Hungary	Hungary 
2.3.8|L&aacute;szl&oacute; Guly?s|Simulation Center of the Informatics Cooperative Research and Education CenterEotvos Lorand University	P&aacute;zm&aacute;ny P&eacute;ter s&eacute;t&aacute;ny 1/c	Budapest	H-1117	Hungary 
2.3.8|Tam&aacute;s Kozsik|Department of Programming Languages and CompilersE&ouml;tv&ouml;s Lor&aacute;nd University	P&aacute;zm&aacute;ny P&eacute;ter s&eacute;t&aacute;ny 1/C	Budapest	1117	Hungary 
3.1.1|Ian Lustick|Political Science DepartmentUniversity of Pennsylvania	United States 
3.1.2|Barry G. Lawson|Department of Computer ScienceCollege of William and Mary	P. O. Box 8795	Williamsburg, VA 23187, USA	United States 
3.1.2|Steve Park|Department of Computer ScienceCollege of William and Mary	P. O. Box 8795	Williamsburg, VA 23187USA	United States 
3.1.forum/1|Warren Thorngate|Psychology DepartmentCarleton University	1125 Colonel By Drive	Ottawa, Ontario	K1S 5B6	Canada 
3.1.forum/2|Dirk Nicolas Wagner|Center for Public ChoiceUniversity of Fribourg	Av. Beauregard 11-13	CH-1700 Fribourg, Switzerland	Switzerland 
3.2.1|Chris Goldspink|270 Wainui Main RoadFrench Farm	Akaroa RD2	7582	New Zealand 
3.2.2|Peter Deadman|University of Waterloo200 University Avenue West	Waterloo	Ontario, Canada	N2L 3G1	Canada 
3.2.2|Randy Gimblett|BSE Bldg. Rm. 325Tucson	Arizona USA	85721	United States 
3.2.2|Edella Schlager|Edella SchlagerSchool of Public Administration and Policy	University of Arizona	Tucson, Arizona,	85721	United States 
3.3.1|Henk de Vos|Department of SociologyGrote Rozenstraat 31	Groningen	The Netherlands.	9712 TG	Netherlands 
3.3.1|Donald Elsas|Netherlands 
3.3.1|Evelien Zeggelink| 
3.3.2|Isobel Fletcher|Environmental Technology GroupUniversity of Paisley	PA1 2BE	Scotland	United Kingdom 
3.3.2|Peter Tucker|Environmental Initiatives GroupHigh Street	PAISLEY	PA1 2BE	United Kingdom 
3.3.forum/2|Joaquim Carvalho|CISUC/IHTIFaculdade de Letras	3049 Coimbra CODEX	University of Coimbra, Portugal	3049	Portugal 
3.4.1|Ilan Fischer|Department of PsychologyUniversity of Haifa	Mount Carmel	Haifa 31905, Israel	Israel 
3.4.1|Ramzi Suleiman|Israel 
3.4.2|Manuel Alfonseca|Tom&aacute;s y Valiente11	Campus de Cantoblanco	Madrid SPAIN	28049	Spain 
3.4.2|Juan de Lara Jaramillo| 
3.4.3|Colm O'Riordan|Ireland 
3.4.4|J. P. Marney|Barking CampusLongbridge Rd.	Dagenham	Essex	RM8	United Kingdom 
3.4.4|Heather F.E. Tarbert| 
4.1.1|Kerstin Dautenhahn|University of HertfordshireCollege Lane campus	Hatfield	Hertfordshire AL10 9AB	United Kingdom 
4.1.1|Steve Coles|Signify Ltd80 London Road	Kingston Upon Thames	Surrey, KT2 6PX, United Kingdom	United Kingdom 
4.1.2|Paolo Petta|Freyung 6/61010	Austria 
4.1.2|Alexander Staller|Institut f&uuml;r InformatikTechnische Universit&auml;t M&uuml;nchen	Boltzmannstr. 3	Garching	85748	Germany 
4.1.3|Rosaria Conte|National Research CouncilInstitute of Cognitive Science and Technologies	V. San Martino della Battaglia 44	Roma	00185	Italy 
4.1.3|Mario Paolucci|LABSS (Laboratory on Agent-Based Social Simulation)Institute of Cognitive Science and Technology	CNR	Via San Martino della Battaglia, 44 Rome, Italy	00185	Italy 
4.1.4|Dietrich  Fliedner| 
4.1.5|Miles Parker|United States 
4.1.6|Klaus Auer|Auer &amp; Luegger GbRIm Wasserblech 59	51107 Koeln - Germany	Germany 
4.1.6|Tim Norris|Environmental Studies1156 High Street	Santa Cruz	CA95064	United States 
4.2.1|Wolfgang Balzer|Germany 
4.2.1|Karl R. Brendel|Weichselgartenstr. 9D-81477 Muenchen	Germany	Germany 
4.2.1|Solveig Hofmann|Schlei&szlig;heimer Str. 94D-80797 Muenchen	Germany	Germany 
4.2.2|Scott Moss|BrookfoldThe Wash	Chapel en le Frith	High Peak	SK23 0QW	United Kingdom 
4.2.3|Bruno Locate
Udine	Italy	78	87
Shahe 	China 	114.55 	36.92 	 	 
Syracuse 	United States of America 	-76.14 	43.04 	 	 
Tib?i 	Taiwan 	121.45 	25.02 	 	 
Pittsburgh 	United States of America 	-79.98 	40.44 	 	 
Cambridge 	United Kingdom 	0.13 	52.21 	 	 
Raman 	India 	0 	0 	 	 
Oulu 	Finland 	25.47 	65.02 	 	 
Tuscaloosa 	United States of America 	-87.54 	33.24 	 	 
Shahe 	China 	114.55 	36.92 	 	 
Christchurch 	New Zealand 	172.64 	-43.53 	 	 
Hongo 	Japan 	0 	0 	 	 
Saint Petersburg 	Russia 	30.32 	59.93 	 	 
Saint Petersburg 	Russia 	30.32 	59.93 	 	 
Tallahassee 	United States of America 	-84.28 	30.46 	 	 
Warwick 	United Kingdom 	-1.59 	52.29 	 	 
Madrid 	Spain 	-3.71 	40.42 	 	 
Berlin 	Germany 	13.38 	52.52 	 	 
Berlin 	Germany 	13.38 	52.52 	 	 
Nanjing 	China 	118.78 	32.05 	 	 
Peking 	China 	116.4 	39.93 	 	 
Peking 	China 	116.4 	39.93 	 	 
Be'er Sheva 	Israel 	34.8 	31.25 	 	 
Bloomington 	United States of America 	-86.52 	39.17 	 	 
Mitaka 	Japan 	139.57 	35.68 	 	 
T?ky? 	Japan 	139.77 	35.67 	 	 
T?ky? 	Japan 	139.77 	35.67 	 	 
Tokai 	Japan 	136.89 	35.03 	 	 
Mitaka 	Japan 	139.57 	35.68 	 	 
Hongo 	Japan 	0 	0 	 	 
Nagoya 	Japan 	136.91 	35.15 	 	 
Toyota 	Japan 	137.16 	35.09 	 	 
Shillong 	India 	91.87 	25.57 	 	 
Huelva 	Spain 	-6.94 	37.25 	 	 
Paris 	France 	2.34 	48.86 	 	 
Mainz 	Germany 	8.26 	50 	 	 
Berlin 	Germany 	13.38 	52.52 	 	 
Sargodha 	Pakistan 	72.67 	32.08 	 	 
Isl?m?b?d 	Pakistan 	73.06 	33.72 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Tbingen 	Germany 	9.06 	48.53 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Tbingen 	Germany 	9.06 	48.53 	 	 
Tbingen 	Germany 	9.06 	48.53 	 	 
Peking 	China 	116.4 	39.93 	 	 
Peking 	China 	116.4 	39.93 	 	 
Peking 	China 	116.4 	39.93 	 	 
Peking 	China 	116.4 	39.93 	 	 
Peking 	China 	116.4 	39.93 	 	 
Lanzhou 	China 	103.68 	36.05 	 	 
Lausanne 	Switzerland 	6.62 	46.52 	 	 
Lausanne 	Switzerland 	6.62 	46.52 	 	 
Neuchtel 	Switzerland 	6.92 	47.01 	 	 
Lausanne 	Switzerland 	6.62 	46.52 	 	 
Lausanne 	Switzerland 	6.62 	46.52 	 	 
Berlin 	Germany 	13.38 	52.52 	 	 
Berlin 	Germany 	13.38 	52.52 	 	 
Street 	United Kingdom 	-2.74 	51.12 	 	 
Brussels 	Belgium 	4.33 	50.83 	 	 
Berlin 	Germany 	13.38 	52.52 	 	 
Rostock 	Germany 	12.1 	54.09 	 	 
Bonn 	Germany 	7.1 	50.73 	 	 
Zagreb 	Croatia 	15.97 	45.8 	 	 
Zagreb 	Croatia 	15.97 	45.8 	 	 
Cologne 	Germany 	6.97 	50.95 	 	 
Saratov 	Russia 	46.03 	51.57 	 	 
Moscow 	Russia 	37.62 	55.75 	 	 
San Cristbal de la Laguna 	Spain 	-16.32 	28.48 	 	 
Cardiff 	United Kingdom 	-3.18 	51.48 	 	 
Cambridge 	United Kingdom 	0.13 	52.21 	 	 
Groningen 	Netherlands 	6.57 	53.23 	 	 
Hangzhou 	China 	120.17 	30.25 	 	 
Hangzhou 	China 	120.17 	30.25 	 	 
Lanzhou 	China 	103.68 	36.05 	 	 
Graz 	Austria 	15.42 	47.08 	 	 
Jena 	Germany 	11.58 	50.93 	 	 
Montreal 	Canada 	-73.57 	45.52 	 	 
Cambridge 	United States of America 	-71.12 	42.38 	 	 
Padova 	Italy 	11.87 	45.41 	 	 
Santander de Quilichao 	Colombia 	-76.49 	3.01 	 	 
Cambridge 	United States of America 	-71.12 	42.38 	 	 
Harvard 	United States of America 	-71.58 	42.5 	 	 
Naples 	Italy 	14.27 	40.85 	 	 
Rome 	Italy 	12.5 	41.89 	 	 
Ithaca 	United States of America 	-76.5 	42.44 	 	 
Cambridge 	United States of America 	-71.12 	42.38 	 	 
Laurel 	United States of America 	-76.86 	39.1 	 	 
Fairbanks 	United States of America 	-147.65 	64.84 	 	 
Goddard 	United States of America 	-76.85 	38.99 	 	 
College Park 	United States of America 	-76.93 	39 	 	 
Moscow 	Russia 	37.62 	55.75 	 	 
Oak Ridge 	United States of America 	-84.3 	35.96 	 	 
Grenoble 	France 	5.72 	45.19 	 	 
Warwick 	United Kingdom 	-1.59 	52.29 	 	 
Toyonaka 	Japan 	135.48 	34.78 	 	 
T?ky? 	Japan 	139.77 	35.67 	 	 
Moscow 	Russia 	37.62 	55.75 	 	 
Minneapolis 	United States of America 	-93.27 	44.96 	 	 
Harvard 	United States of America 	-71.58 	42.5 	 	 
Michigan Center 	United States of America 	-84.33 	42.23 	 	 
Baton Rouge 	United States of America 	-91.13 	30.45 	 	 
Montevideo 	Uruguay 	-56.17 	-34.87 	 	 
Gif-sur-Yvette 	France 	2.13 	48.68 	 	 
So Paulo 	Brazil 	-46.63 	-23.53 	 	 
So Paulo 	Brazil 	-46.63 	-23.53 	 	 
Mitaka 	Japan 	139.57 	35.68 	 	 
Santa Barbara 	United States of America 	-119.72 	34.43 	 	 
Heidelberg 	Germany 	8.69 	49.42 	 	 
Ann Arbor 	United States of America 	-83.73 	42.28 	 	 
Tucson 	United States of America 	-110.89 	32.2 	 	 
Hefei 	China 	117.28 	31.85 	 	 
Tib?i 	Taiwan 	121.45 	25.02 	 	 
Tucson 	United States of America 	-110.89 	32.2 	 	 
Saint Petersburg 	Russia 	30.32 	59.93 	 	 
Tsukuba 	Japan 	140.09 	36.21 	 	 
Santiago de Compostela 	Spain 	-8.54 	42.88 	 	 
Santiago de Compostela 	Spain 	-8.54 	42.88 	 	 
Orsay 	France 	2.18 	48.7 	 	 
Gif-sur-Yvette 	France 	2.13 	48.68 	 	 
Santiago de Compostela 	Spain 	-8.54 	42.88 	 	 
Gif-sur-Yvette 	France 	2.13 	48.68 	 	 
Gif-sur-Yvette 	France 	2.13 	48.68 	 	 
Orsay 	France 	2.18 	48.7 	 	 
Santiago de Compostela 	Spain 	-8.54 	42.88 	 	 
Orsay 	France 	2.18 	48.7 	 	 
Orsay 	France 	2.18 	48.7 	 	 
Orsay 	France 	2.18 	48.7 	 	 
Gif-sur-Yvette 	France 	2.13 	48.68 	 	 
Gif-sur-Yvette 	France 	2.13 	48.68 	 	 
Ithaca 	United States of America 	-76.5 	42.44 	 	 
Cambridge 	United States of America 	-71.12 	42.38 	 	 
Laurel 	United States of America 	-76.86 	39.1 	 	 
Fairbanks 	United States of America 	-147.65 	64.84 	 	 
Goddard 	United States of America 	-76.85 	38.99 	 	 
College Park 	United States of America 	-76.93 	39 	 	 
Pittsburgh 	United States of America 	-79.98 	40.44 	 	 
Pasadena 	United States of America 	-118.14 	34.16 	 	 
Ellicott City 	United States of America 	-76.83 	39.27 	 	 
London 	United Kingdom 	-0.1 	51.52 	 	 
Urbana 	United States of America 	-88.21 	40.11 	 	 
Lexington 	United States of America 	-84.46 	38.04 	 	 
Irvine 	United States of America 	-117.8 	33.66 	 	 
Pittsburgh 	United States of America 	-79.98 	40.44 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
Haifa 	Israel 	34.99 	32.82 	 	 
Bloomington 	United States of America 	-86.52 	39.17 	 	 
Haifa 	Israel 	34.99 	32.82 	 	 
Cambridge 	United States of America 	-71.12 	42.38 	 	 
cole-Valentin 	France 	5.98 	47.27 	 	 
Paris 	France 	2.34 	48.86 	 	 
Brookhaven 	United States of America 	-72.92 	40.78 	 	 
Harvard 	United States of America 	-71.58 	42.5 	 	 
So Carlos 	Brazil 	-47.89 	-22.02 	 	 
New York 	United States of America 	-73.94 	40.67 	 	 
Zurich 	Switzerland 	8.54 	47.38 	 	 
Tarragona 	Spain 	1.24 	41.12 	 	 
Tarragona 	Spain 	1.24 	41.12 	 	 
Barcelona 	Spain 	2.17 	41.4 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
Oulu 	Finland 	25.47 	65.02 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
New Haven 	United States of America 	-72.92 	41.31 	 	 
Golden 	United States of America 	-105.22 	39.74 	 	 
West Lafayette 	United States of America 	-86.91 	40.44 	 	 
Prague 	Czech Republic 	14.43 	50.08 	 	 
Austin 	United States of America 	-97.75 	30.31

while a particular text stored in a scalar variable and the text having any meta characters " \ | ( ) [ { ^ $ * + ? . " , when the scalar variable used to match any string, at the time the above type of error appeared. Better you will be use "quotemeta" function for this case.

http://www.tutorialspoint.com/perl/perl_quotemeta.htm


you will be modify the below lines in your code.

my $country1=quotemeta($aj2[$i]);
      my $city1=quotemeta($aj1[$i]);

Ok thanks that solves the problem to certain extent but still i am not able to compare all the cities and countries and print them ..however, few of them matches ..what can be a problem??

Many of the city and country values in the city_lan.txt have a trailing space character, whereas the city and country values in your address_out.txt input file do not have trailing spaces and so don't match.

Try modifying the first split statement to allow for the possibility of a space preceding the tab separating the city from country in your city_lan.txt input file. Add a space followed by ? to match one or fewer spaces followed by the \t. The statement will look like this:

#Modified the following to split on one or no space followed by tab
    my($city,$country,$lan,$lat) = (split(/ ?\t/))[0,1,2,3];

This should eliminate the trailing space from the city and country values which could be one cause for failed matches.

it shud print it afterwards sumwhat like this:
1.1.2|1. Giorgio Brajnik 2. Marji Lines |1. Dipartimento di Matematica e InformaticaUniversit&agrave; di Udine Udine Italy Italy 2. Dipartimento di Scienze StatisticheUniversit&agrave; di Udine Udine Italy 33100 Italy |Udine|Italy|78|87

You want the output for ID #1.1.2 to look like the above, right? What I get in the output file looks as follows:

1.1.2|Giorgio Brajnik|Dipartimento di Matematica e InformaticaUniversit&agrave; di Udine	Udine	Italy	Italy 
|Udine|Italy|78|87

1.1.2|Marji Lines|Dipartimento di Scienze StatisticheUniversit&agrave; di Udine	Udine	Italy	33100	Italy 
|Udine|Italy|78|87

Is why you say it doesn't work? Apart from that can you show us another line in the address_out.txt file that should have matches in the city_lan.txt file which are not printed in the output?

Do you still need a program like this? If it's important we can probably improve the results, but how good the results are depends of course on the input data. For example: /to\?ky\?/ will not match "Tokyo". The quotemeta function added the backslashes before the question mark and that avoids the run-time error you were getting but the resulting pattern tries to match a literal '?' in the string so it will not match "Tokyo". Also "United States of America" in the city_lan.txt file will never match "United States" in the address_out.txt file. If you will need to process more data like these in the same format then maybe it would be worth trying to solve all these inconsistencies in the data with a program. Otherwise you may just have to yell at the person who created the city_lan.txt file.:)

Hi
Thanks for the help...actually I am finally done with matching all the data...which did require some manual curation and ya, I agree with the fact that the input data was the real problem.

Congratulations. That turned out to be harder than it looked at first.

The problem of printing one record consolidating all the authors and addresses for each $jas also turned out to be harder than it looked, at least for me. In fact, I never got that part working quite right. Anyway, you're done now, so that's good.

This article has been dead for over six months. Start a new discussion instead.