trying to get perl regex to "find" multi-line AND single-line HTML comments in an HTML file.... :     I'm reading in an html file, trying to find HTML comments, both single and multi-line. I've stripped it down to just a few examples, and some other  content just to have something there. 
    I've read a lot of the entries here, can't get a definitive answer to this... I'm reading in the html file in "slurp" mode, and doing a match of my pattern.. this code runs now and produce 1 (the first) match.. 


    #!C:\Perl\bin\perl.exe 
    BEGIN {  unshift @INC, 'C:\rmhperl';} 
    use warnings;no warnings 'uninitialized';
    chdir 'c:\watts\html'; 
    open FILE, "test.html" or print 'error opening file "test.html" ';
    my $text = do { local $/; <FILE> };
    close(FILE);
     if ($text =~ m/(?s)(<!--.*?)(-->\n)/sg) {
       print "1 = $1  2= $2\n";
     }
    exit;

   in my html file, I've set up single and multi-line html comments... I can get the first OR the last to appear, but not EVERY one (at least in "slurp" mode)...  
   I'm told I should be able to  accomplish this with one regex... so the objective is "find ALL HTML comments, regardless of their being single/multi-line comments"... 
  so I built the regex to find both... it doesn't find the single-lines, and only finds 1 match... 
  I'm trying to  find switches/way to tell regex to find EVERY match, whether it occurs on one line, or is a multi-line... I can do it either/or, but can't get them to work with one regex... 
  I can do non-slurp mode, and find the "<!--" tag, then loop until I see the "-->" tag, but wanted to see if I can get it to work... 
  I've been reading about this, and trying to find relevant examples... can't see what I'm missing... Here's the HTML file snippet I have been using for the regex: 

#########################1st line of html file below #########################

    <!DOCTYPE html>
     
    <script type="text/javascript" src="fadeslideshow.js"></script>
    <style>
    
    .divTable {
    	display: block;
    	width: 100%;
    }
    
    .divTableBody, .divTableRow{ clear: both; }
    
    .divTableCell {
     	border: 1px solid #999999;
    	float: left;
    	overflow: hide;
    	padding: 2%;
    	width: 45%; }
    
    .divTable:after {
    	display: block;
    	font-size: 0;
    	content: " ";
    	clear: both;
    	height: 100px; }
    </style>
    <style type="text/css">
    <!--
    a:link {color: #0000ff;}
     a:visited {color: #3563a8;} 
     a:active {color: #000000;}
     a:hover {background-color: #000000;}
     a {text-decoration: none;}
     -->
     </style> 
    </head>
        <body class="home">
    
     <div id="white_back">
    <div style="text-align: center">
    </div>
    <div class="chromestyle" id="chromemenu">
    <ul>
    <!-- <li><a href="xyz.com">Home</a></li>
     -->
     <li><a href="#" rel="dropmenu0">About Us</a></li>
    <li><a href="#" rel="dropmenu5">Publications</a></li>	
    </ul>
    </div>
    
    <!--1st drop down menu
    -->                                                   
    <div id="dropmenu0" class="dropmenudiv">
    </div>
    
    <!--2nd drop down menu -->
    <div id="dropmenu1" class="dropmenudiv">
    </div>

#########################last line of html file above#####################

  any help, or rtfm reference link appreciated...

  Mickey Holliday


   


