Update: This was intended as a reply to this post.

can i compare individual string with complete array ...

I don't have the time or means at the moment (I have no easy access to Excel) to build an Excel test spreadsheet and write a test script to run against it. I also, of course, cannot examine your code in the context of the full script in which it works. What happens when you run this code (perhaps in a small test script) against your own test spreadsheet? Are the results as you expect? Do you understand the example code given here? I mentioned the  (?i) regex "operator" in that reply just for your information; I didn't mean to imply that it was necessary to use it.

Just by visual inspection, I can make some comments on the code.

The
    grep { /(?i)\Q$db_description\E/ } @steps_name
expression in your code will evaluate true (in boolean context) if  $db_description is a case-insensitive match with any element in the  @steps_name array. This seems in accord with the messages being printed in the true/false clauses of the if-statement.

However, in the
    print "<br><h1>Element '$db_description' found $steps_name[$row+1] --- $seq_code[$row+1] !</h1></br>" ;
statement, the  $row variable has a range of up to 50 (in your example code), and the  @steps_name array has only four elements. The  $row+1 index can potentially be far outside the bounds of the  @steps_name array! I don't understand this bit. I also have no idea what's in the  @seq_code array and so cannot comment further.

The
    my $needle_regex = quotemeta $db_description;
statement is completely unnecessary;  $needle_regex is never used, and  \Q$db_description\E in the regex completely meta-quotes the interpolated variable.

Good questions get good answers. I must say I find your question confusing, and it's a bit frustrating to try to answer it.


Give a man a fish:  <%-{-{-{-<


In reply to Re^4: regex for case insensitive by AnomalousMonk
in thread regex for case insensitive by rohan_532

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.