Ok, to be more clear.

I have this code:
#!/usr/bin/perl -w use strict; my $patterns = "/path/to/patterns.txt"; my $arg1 = shift; open (PAT, '<', $patterns) or die "$patterns: $!\n"; my @patterns = <PAT>;. close(PAT); chomp @patterns; my $regex_string = join '|', @patterns; open( FILE, "<", "$arg1") or die "$arg1: $!\n"; $_ = do { local $/; <FILE> }; close(FILE); if ( /($regex_string)/is ) {print "\n$arg1\n$1\n";}
Test list with patterns:
/path/to/patterns.txt
part1.*part2 Foo bar Other pattern
Test file to scan:
hghghgghghh part1 fff part2 jhhjhjkjk Foo bar kkjkjkj Other pattern
$1 will show all wildcarded text between part1 and part2 and not only the pattern part1.*part2 as it should.
/path/to/file part1 fff part2

Also, only first pattern found is displayed now. That's not a problem, but I'd also like to know how to display all patterns if a file contains more than one.
Please bear an unexperienced user like me. Thank you!
Regarding the other problem with xml file to scan, I must do more tests to know exactly where the problem is.

In reply to Re^4: Comparing pattern by mrc
in thread Comparing pattern by mrc

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.