You could use a hash to keep track of which search strings have been found (but you need to make sure the strings are unique):
use strict; use warnings; #Data contained in the TXT File ARRAY my @dataArray = ("12/12-08:01:22.360401 *** [945850] pr0", "12/13-08:03:22.420449 *** [948851] pr1", "12/16-08:04:22.439726 *** [948852] pr0", "12/17-08:10:22.440649 *** [948853] pr1", "12/17-08:10:22.444688 *** [948854] pr1", "12/17-08:10:22.512471 *** [948855] pr2", "12/17-08:10:22.512471 *** [948856] pr0", "12/17-08:10:22.527738 *** [948857] pr1", "12/17-08:10:22.527888 *** [948858] pr3", "12/17-08:10:22.527898 *** [948859] pr2", "12/17-08:10:22.527999 *** [948860] pr2", "12/17-08:10:22.528999 *** [948861] pr2", "12/17-08:10:22.529999 *** [948862] pr2" ); #Search strings that must much - ARRAY form. my @arrayOfSearchStrings = map { "[$_]" } 945850 .. 945852; my %found; for (@dataArray) { for my $pat (@arrayOfSearchStrings) { $found{$pat}++ if /\Q$pat/; } } if (@arrayOfSearchStrings == (keys %found)) { print "Found ALL SEARCH STRINGS required in ARRAY\n"; } else { print "Did not find all needed search strings\n"; } __END__ Did not find all needed search strings

Update: This may be faster since it stops looking though the dataArray as soon as it finds all your search strings:

#Search strings that must much - ARRAY form. my @arrayOfSearchStrings = map { "[$_]" } 945850 .. 945852; my %searchStrings = map { $_ => 1 } @arrayOfSearchStrings; OUTER: for (@dataArray) { for my $pat (keys %searchStrings) { if (/\Q$pat/) { delete $searchStrings{$pat}; last OUTER unless %searchStrings; } } } if (%searchStrings) { print "Did not find all needed search strings\n"; } else { print "Found ALL SEARCH STRINGS required in ARRAY\n"; }

In reply to Re: Search an array for array of strings by toolic
in thread Search an array for array of strings by perlnewbie9292

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.