Nothing is done with | No change is made to the default value of  $/ (the input record separator; see perlvar), so readline (the  <$fh> expression) is reading newline-terminated lines. Then chomp removes the  $/ sequence (the newline) from each line. The  /.{20}\\[a-zA-Z]\s[\r\n]/ regex requires a  [\r\n] (carriage-return or newline) character to match, but chomp has removed the newline, and I doubt there is a  \r present with which to match in text that seems to come from a Windows directory listing (update: see this for a more thorough discussion of this point).

c:\@Work\Perl\monks>perl -wMstrict -le "print 'match with \r' if qq{ Directory of D:\\ \\Q\\X \r} =~ /.{20}\\ +[a-zA-Z]\s[\r\n]/; print 'match sans \r' if qq{ Directory of D:\\ \\Q\\X } =~ /.{20}\\ +[a-zA-Z]\s[\r\n]/; " match with \r

Update: Beyond that, the
    next if $row =~ /REGEX/;
statement will skip printing if there is a match. You seem to want to print the line if there is a match, so something like
    next unless $row =~ /REGEX/;
still seems the way to go (once you get the regex right :) (Update: See also Marshall's reply. It seems like really good advice, although I see no need to stringize  "$line" when  $line is already a string read from a file.)


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


In reply to Re^3: How do I display only matches (updated) by AnomalousMonk
in thread (SOLVED) How do I display only matches by tem2

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.