Hi there Monks!
Can someone explain why this code does not match on my code? I have to use regular expression for this.
Thank you very much!!!

#!/perl/bin/perl use CGI qw(:header); use CGI::Carp qw(fatalsToBrowser); use CGI qw/:standard/; use strict; print header(); use warnings 'all'; my $directory = "/test"; my $new_file = "$directory/test.txt"; my $out_put; open(FH,'<',$new_file) || die $!; my @test = <FH>; foreach my $line (@test) { $line =~ /<!--\s+\d+nd movie -->\s*(.*?)\s*<!--\s+\/\d+nd movie -- +>/sgi; $out_put = $1; print $out_put; } close(FH);

Here is the test.txt file, I am trying to get whatever is in between tags - <!-- 1nd  --><!-- /1nd table --> and <!-- 2nd table --><!-- /2nd table -->:


test.txt
<!-- 3nd table --><table cellpadding="0" cellspacing="0" border="0"><t +r><td>Test Line no end of line.</td</tr></table><!-- /3nd table --> <!-- 1nd --> <table cellpadding="2" cellspacing="0" border="0"><tr><td><font color= +red>Test Line</font></td></tr></table> <!-- /1nd table --> <!-- 4nd table --><table cellpadding="0" cellspacing="0" border="1"><t +r><td><font color=navy>Test Line no end of line.</font></td></tr></ta +ble><!-- /4nd table --> <!-- 2nd table --> <table cellpadding="0" cellspacing="0" border="0"><tr><td>Test Line no + end of line.</td</tr></table> <!-- /2nd table -->


Thank you very much!!!

In reply to Regular Expression Matching Issue by Anonymous Monk

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.