G'day neeraj_kr,

Welcome to the Monastery.

Your posted question is lacking important information. You do not show: sample input; actual output; expected output; or, warning or error messages. Saying "it's not working properly" is a pretty much useless error report: would you take a car to a mechanic, provide just that information, then walk away? Please read "How do I post a question effectively?".

Your code, in general, leaves much to be desired. I'd recommend, in the first instance, that you read "perlintro -- Perl introduction for beginners". When you've done that, apply what you've learned and rewrite your code. Some areas that stand out as needing attention, include:

Your @arr1 array, with what looks like a couple of hundred elements, is fairly pointless. What is this supposed to tell us? Is there any sort of order or pattern to this data? Did you expect us to analyse this for you (without the benefit of your domain-specific knowledge)? Pick a discrete sample of representative data for your SSCCE.

There are two general approaches to what you want to do. Without any knowledge of your input data, I'm not in a position to advise which might be best, or how you would implement it. One method involves storing your keywords in a hash then using exists; the other uses regular expression alternations (see perlre; although, you might want to look at perlretut first).

Your "@arr2=split(/\,/,$_);" line of code suggests you're reading CSV data. Use Text::CSV for this; if you also have Text::CSV_XS installed, it will run faster.

That's a lot of reading, things to fix, and additional information to provide. Once completed, you may have additional questions: please post these with this thread (not as new, separate questions).

— Ken


In reply to Re: Data extraction with specific keywords by kcott
in thread Data extraction with specific keywords by neeraj_kr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.