Hello dear esteemed monks!

I'm looking for a way to test multiple lines to match corresponding regular expressions:

multi_like \@array, [ qr/regex1/, qr/regex2/, .... ], "Test name";

Now obviously I can do it with a subtest and like statements, plus one test for length:

subtest "All lines are like expected" => sub { like $array[0], qr/regex1/; like $array[1], qr/regex2/; .... is scalar @array, $nnn, "No extra lines"; };

And I can do it with one go with Test::Deep, although I haven't yet found out how to make it report the full difference and not just the first mismatch.

But maybe there's a module that does exactly that (matches a list of strings against a list of regexps)?

Thanks!


In reply to Test:: to match multiple lines against corresponding regular expressions by Dallaylaen

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.