in reply to Re: shell commands doesn't integrate with perl
in thread shell commands doesn't integrate with perl
i am posting a few lines from the data files and a modified script but the problem am facing is that @ each run of the loop it just scans the whole file and not the single line.
#!/usr/bin perl open(DAT,">final_result"); open(HANDLE,"<labels"); while($line=<HANDLE>) { chomp($line); ($english_index,$hindi_index,$nua)=split(/\|/,$line); @english=split(/:/,$english_index); @hindi=split(/:/,$hindi_index); for($j=0;$j<=$#english;$j++) { $eng_dat=`grep --regexp '$english{$j}' /home/vikash/pr +o_1/en_1000`; print DAT $eng_dat; } for($j=0;$j<=$#hindi;$j++) { $hindi_dat=`grep --regexp '$hindi{$j}' /home/vikash +/pro_1/HI_1000`; print DAT $hindi_dat; } print DAT "************************************************** +***************\n"; } close DAT; __END__
the sample labels data file is
EN-1000-0002-1|HI-1000-0001-1:HI-1000-0002-1| EN-1000-0003-1|HI-1000-0003-1| EN-1000-0003-2|HI-1000-0003-2| EN-1000-0003-3|HI-1000-0003-3| EN-1000-0004-1:EN-1000-0004-2|HI-1000-0004-1| EN-1000-0004-3|HI-1000-0005-1| EN-1000-0005-1|HI-1000-0005-2| EN-1000-0005-2|HI-1000-0005-3| EN-1000-0006-1|HI-1000-0006-1| EN-1000-0006-2:EN-1000-0006-3|HI-1000-0006-2| EN-1000-0008-1|HI-1000-0008-1:HI-1000-0008-2| EN-1000-0008-2:EN-1000-0008-3|HI-1000-0008-3|
n the sample en_1000 file is
<p id=EN--1000-0002-1> Nehru Bal Pustakalaya THE COSMIC GIFT Mohan S +undara Rajan Neeta Gangopadhya National Book Trust, India UNDER TH +E SEA An Indian research submarine was exploring the ocean-bed off t +he coast of Parson's Pygmalion Point, the southern-most tip of India. + Its young Captain, Uttama, and his crew gazed entranced at the stran +ge world under water, strangely lit here and there with many-shaped c +oral reefs, amidst which innumerable varieties of colourful fish and +creatures of weird shapes flitted. </p> <p id=EN--1000-0003-1> Then a sharp order came through. All movement m +ust be halted. A naval exercise was planned. </p> <p id=EN--1000-0003-2> The engines were turned off. All was still and +waiting. Suddenly, Uttama spotted a peculiar object lying among the c +oral. It was smooth and of a single unusual colour among the infinite + variety around it. It did not resemble any living creature. Curious. + Uttama ordered it be captured. </p> <p id=EN--1000-0003-3> The object turned out to be a big meteorite. Ut +tama was delighted. He had never seen anything like it on sea or land + before. Despite its journey in space and stay in water, it had retai +ned its shape and colour. </p> <p id=EN--1000-0004-1> The stand-still alert ended. Uttama was ordered + to surface. He immediately telephoned his friend, Professor Maruthi +of the Stellar School in the Kavalur Observatory complex and informed + him about the meteorite. </p> <p id=EN--1000-0004-2> Professor Maruthi was very excited. The meteori +te was the largest he had ever heard of. Receiving permission to exam +ine it Professor Maruthi began conducting tests on the cosmic relic. + </p> <p id=EN--1000-0004-3> As layer after layer of filmy material was remo +ved, a clear pattern emerged, looking like 10101 which Professor Maru +thi suggested was a binary code for 21. And 21 could stand for the 2 +1 cm. radio frequency of hydrogen in space. </p> <p id=EN--1000-0005-1> Was it a message from some intelligent beings i +n outer space? </p> <p id=EN--1000-0005-2> For many years scientists on earth had been sen +ding out messages of coded primary mathematics in the hope of these b +eing picked up but so far there had been no answer. Could this be it? + </p> <p id=EN--1000-0006-1> MESSAGE FROM A METEORITE News of the meteorite + and its binary content were broadcast by all radio stations in the w +orld. Immediately, a furious debate broke out. The Americans announce +d that they would make special spacecraft and set off to explore the +territory from which the outer space beings had sprung. The Russians, + on the other hand, wanted to move cautiously and wait till fuller co +ntact through the binary code was established. </p> <p id=EN--1000-0006-2> There were also telegrams pleading for a halt t +o further communication lest another civilisation assess our technolo +gy as primitive. Others, however, argued that the intentions of any c +ivilisation which could survive so long might not be evil. Contact wi +th it need not prove dangerous and could even be greatly beneficial. + </p> <p id=EN--1000-0006-3> Professor Maruthi went ahead with preparations +to send a message to outer space. He suggested a method to code the m +essage that would be recognised as undoubtedly coming from intelligen +t beings. He said that the message could be sent in a single successi +on of 'On-Off pulses of radiation. The pulses could represent ones a +nd their absence zeros. Thus a binary series of numbers would be tran +smitted. Again, these numbers could be the first twelve primary numbe +rs, viz. 1, 2, 3, 5, 7, 11, 13,17,19, 23, 29 and 31. This would indic +ate simple mathematical knowledge which could only come from intelli +gent beings. There was even a possible method of arranging such a mes +sage to give a clear description. By putting an array of 29 groups of + 19 squares, for example, and by colouring the ones black and zeros w +hite, an interesting picture could be shown, indicating the physical +appearance of human beings, how the solar system functioned and other + important facts. </p>
the sample hi_1000 file
<p id=HI--1000-0001-1> 1 अंतरिक +381;ष का वरदान न +;ेहरु बाल पु +360;्तकालय अं&# +2340;रिक्ष का वर +;दान मोहन सु +ंदर राजन नी& +#2340;ा गंगोपाध् +;याय सुरेश उ +नियाल नेशन& +#2354; बुक ट्रस्é +5;, इंडिया 2 अंê +0;रिक्ष का वर&# +2342;ान ISBN 81-237-0945-5 +पहला संस्कë +2;ण : 1983 बारहवीं +आवृत्ति : 2001(शè +5; 1922) मूल मोहन स +ुंदर राजन, 1983  +361;िंदी अनुवा& +#2342; नेशनल बुक  +35;्रस्ट, इंडि& +#2351;ा, 1983 A Comic Gift (Hindi) रु0 9.00 & +#2344;िदेशक, नेशê +4;ल बुक ट्रस्&# +2335;, इंडिया, ए- 5 ग +्रीन पार्क &# +2344;यी दिल्ली- 11001 +6 द्वारा प्र +325;ाशित </p> <p id=HI--1000-0002-1> भारत के +दक्षिणी छोë +2; के इंदिरा प& +#2377;इंट के तट स +75; लगे हुए साग +र तल पर एक भा&# +2352;तीय खोजी पन +;डुब्बी खोज +48;ीन कर रही थी +| कप्तान उत् +340;म और उसके दल +; के अन्य लोग & +#2346;ानी के भीतë +2; की उस विचित& +#2381;र दुनिया कí +9; बडे अचरज से +देख रहे थे| इ&# +2343;र-उधर कई आकì +6;रों में मूं&# +2327;ों की चटटान +;ें चमक रही थ&# +2368; और उनके भीê +0;र कई किस्म क& +#2368;, रंग विरंग +68; मछलियॉ और अ +लौकिक आकारí +9;ं वाले जीवन & +#2350;ंडरा रहें ê +1;े| </p> <p id=HI--1000-0003-1> तभी एक क&# +2336;ोर आदेश सुन +;ाई दिया| जो ज& +#2361;ां हैं वही  +52;ुक जाये| नौस +ैनिक अभ्याì +0; चल रहा है| </p> <p id=HI--1000-0003-2> इंजन बं +342; कर दिये गये +;| सब कुछ शांत +होकर ठहर गय +66;| अचानक उत्त +म को मूंगे क +368; चटटानों के + बीच में एक व&# +2367;चित्र सी ची +;ज पडी हुई दि&# +2326;ाई दी| यह चि +25;नी सी चीज थी + और आसपास की &# +2352;ंग-बिरंगी च +;ीजों के बीच &# +2351;ह असामान्य + से एक ही रंग & +#2325;ी थी| यह किस +368; भी जीवित जं +;तु से नहीं म&# +2367;लती थी| जिजî +1;ञासु उत्तम &# +2344;े उसे उठा लì +6;ने का आदेश द& +#2375; दिया| </p> <p id=HI--1000-0003-3> यह एक बड&# +2375; आकार का उलî +1;का पिंड था| उ +त्तम बहुत ख +69;श हुआ| उसने ऐ +;सी कोई चीज क&# +2349;ी पहले नहीं +; देखी थी- न सम +ुद्र में और  +344; जमीन पर| अंê +0;रिक्ष यात् +352;ा और पानी मे +;ं रहने पर भी & +#2311;स चीज का रं +27; और आकार नही +ं बदला था| </p> <p id=HI--1000-0004-1> 4 अंतरिक +381;ष का वरदान ठ +;हरे रहने की &# +2330;ेतावनी खत् +म हो गयी थी| उ& +#2340;्तम ने ऊपर  +32;ाने का आदेश +दिया| पहुंच +40;े ही उसने अप +ने मित्र का +57;ालूर बेधशा&# +2354;ा क्षेत्र म +;ें स्थित ता +352;ामंडल स्कू& +#2354; के प्रोफेì +0;र मारुति को & +#2335;ेलीफोन किय +;ा और इस उल्क&# +2366; पिड के बारí +5; में उन्हें & +#2348;ताया| प्रोê +7;ेसर मारुति &# +2348;हुत उत्साह + में आ गये थे| +अब तक उन्हो +06;ने जितने भी +उल्का पिंडí +9;ं के बारे मे& +#2306; सुना था, यह &# +2313;न सबसे बडा ê +1;ा| इसका परीक& +#2381;षण करने की  +09;नुमति मिलत&# +2375; ही प्रोफेस +;र मारुति ने &# +2309;ंतरिक्ष के + इस अवशेष पर &# +2346;रीक्षण करन +ा शुरु कर दि +351;ा| </p> <p id=HI--1000-0005-1> 5 इस पर जम& +#2368; बाहरी तहोæ +6; को उतारने क& +#2375; बाद एक स्प +59;्ट आकृति सा& +#2350;ने आयी जो 10101 é +2;ैसे दिख रही & +#2341;ी| प्रोफेसë +2; ने बताया कि +यह 21 का दिवचर +प्रणाली का  +52;ुप है| और 21 का &# +2309;र्थ अंतरिक +्ष में हाइड +81;रोजन की 21 सेæ +6;टीमीटर रेड +367;यों आवृत्त& +#2367; है| </p> <p id=HI--1000-0005-2> कही यह ब&# +2366;ह्रय अंतरि +क्ष के किसी  +360;मझदार प्रा& +#2339;ी का संदेश  +40;ो नहीं है| </p> <p id=HI--1000-0005-3> कई वर्ष +379; से पृथ्वी क +;े वैज्ञानि +25; सांकेतिक प& +#2381;राथमिक गणि +;तीय संदेशो +06; को इस आशा के +; साथ बाहर भे&# +2332;ते हैं कि उê +4;्हें कोई ग्&# +2352;हण करेगा| पë +2; अभी तक तो को +ई जवाब नहीं  +350;िला था| क्या +; यह कोई जवाब & +#2361;ो सकता है? </p> <p id=HI--1000-0006-1> 6 अंतरिक +381;ष का वरदान उ +;ल्कापिंड स +75; प्राप्त सं& +#2342;ेश इस उल्क +366;पिंड और इसक +े दिवचर संद +75;श की खबर पूर +ी दुनिया के  +352;ेडियो स्टे& +#2358;नों से प्रì +0;ारित हो गयी| +अमरीकियों ê +4;े घोषणा की क& +#2367; वे एक विशे +59; अंतरिक्ष य& +#2366;न बनायेगें +; और इसे बाह्&# +2352;य अंतरिक्ष + के उस क्षेत +381;र की खोज के ë +4;िए भेजेंगे &# +2332;हॉ नये जीव è +5;ा अभ्युदय ह&# +2369;आ है| दूसरी  +23;र रुसी लोग स +ावधानी से ह +68; कोई कदम उठा +ना चाहते थे  +324;र तब तक प्रत +;ीक्षा करना  +330;ाहते थे जब त +;क कि दिवचर प&# +2381;रणाली से ही +;, उनसे पूरी त& +#2352;ह संपर्क नì +1;ी कर लिया जा& +#2340;ा| </p> <p id=HI--1000-0006-2> बहुत से &# +2335;ेलीग्राम इ +स बात की वका +354;त कर रहे थे è +5;ि किसी भी तर& +#2361; के संचार क +79; रोक दिया जा +ये, कहीं ऐसा &# +2344; हो कि वह दू +60;री सम्यता ह& +#2350;ारी प्रौद् +;योगिकी को अ +349;ी आदिमकाली& +#2344; ही समझ् रह +68; हो| कुछ और लí +9;गों का तर्क & +#2341;ा कि जो सभ् +51;ता इतने समय +तक जीवित कर  +360;कती हैं, उसक +;े इरादों के &# +2348;ुरे होने की +; संभावना कम &# +2361;ी लगती है| इ +60;के साथ संपर& +#2381;क खतरनाक सì +7;द्व नहीं हो&# +2327;ा बल्कि लाभ +;कारी ही हो स&# +2325;ता है| प्रोê +7;ेसर मारुति &# +2348;ाह्रय अंतर +िक्ष में भे +32;ने के लिए सं +देश तैयार क +52;ने में लग गय +े| उन्होंने +06; संदेश का सं +केत करने की  +319;क ऐसी प्रणा +ली तैयार की  +332;ो निस्संदे& +#2361; समझ्दार पî +1;राणियों द् +357;ारा भेजी गय +ी ही मानी जा +351;ेगी| उन्हों +ने कहा कि वि +325;िरण की ‘ऑन-आ +फ’ के एक अनु +25;्रम द्वारा & +#2360;ंदेश भेजा é +2;ा सकता 7 है| त&# +2352;ंग का अर्थ ì +1;ोगा एक और न ह +ोने का अर्थ  +361;ोगा शून्य| इ +;स प्रकार दि +357;चर श्रेणी क +ी संख्याओं  +25;ो प्रेषित क& +#2367;या जा सकता  +61;ैं| फिर, ये सæ +6;ख्याऍ पहली &# +2348;ारह रुढ संख +;्याऍ भी हो स&# +2325;ती है- 1,2,3,5,7,11,13,17,19,23,29,31 &# +2351;ह सामान्य ग +;णितीय ज्ञा +44; की ओर इंगित + करेगा जो सि +352;्फ 8 अंतरिकî +1;ष का वरदान स& +#2350;झदार प्राण +;ियों की ओर स&# +2375; ही आ सकता ह +76;ं एक स्पष्ट +विवरण देने  +25;े लिए इस प्र +कार के संदश  +325;ो क्रमबद्व +करने की प्र +39;ाली भी तैया& +#2352; की जा सकती  +361;ै| 19 वर्गो के 29 + समूहों के व +367;न्यास से–म&# +2360;लन ईकाईयो क +;ो काला और शू&# +2344;्यो को सफेद +; करके- एक दिल& +#2330;स्प चित्र ê +8;नाया जा सकत&# +2366; हैं जो मानë +7; अस्तित्व क&# +2375; भौतिक स्वर +;ुप, सौर प्रण&# +2366;ली की कार्य +;विधि तथा अन +381;य महत्वपूर& +#2381;ण तथ्यों कí +9; प्रकट कर सक& +#2340;ा है| </p> <p id=HI--1000-0008-1> तभी आयु +352;्विज्ञान अ& +#2344;ुसंधान परि +;षद की ओर से ए& +#2325; संदेश मिलì +6;| जीव रसायन व +िभाग के अध् +51;क्ष डाक्टर & +#2343;नवंतरी कह ë +2;हे थे| </p>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: shell commands doesn't integrate with perl
by bart (Canon) on Jul 24, 2011 at 11:14 UTC |