I am trying to read this text file and extract the values into the $1,$2 so forth variables, but it seems not to work. It's not letting me match the <?--1-1--> and </?--1-1--> tags. Any help on how I could to the match and use its values stored into the variables above? Thanks a lot!!!!! Here is the text file I am trying to do the match against:
<?--1-1--> <b>This is option 1 ok</b> </?--1-1--> <?--1-2--> <b>This is option 1 version b</b> </?--1-2--> <?--1-3--> <b>Option 1 version 3</b> </?--1-3--> <?--1-Version4--> <b>Option 1 version 4 Perl</b> </?--1-Version4-->

Here is the piece of the code trying to extract the information from the text file.
my $filename="test.txt"; my $template_data = "/content".$filename; open(DATA_IN, "$template_data") || print "Can't open output file1: + $template_data\n"; #my @file = <DATA_IN>; # read it into @file #foreach my $line (@file){ #chomp($line); #print @file; while(<DATA_IN>){ # if($line =~/^(<\?--\.*\-\.*\-->)\s(.*)\s(<\/\?--\.*\-\.*\-->)\ +s/ig){ # if($_=~/^<\?--(.*)-(.*)-->(.*)<\/\?--(.*)-(.*)-->/){ # if($_=~/(<\?--(.*)-(.*)-->)(.*)(<(.*)>)/g){ #<?--1-1--> if($_=~/^<\?--(.*)-(.*)-->(.*)<\/\?--(.*)-(.*)-->/g){ # if($_=~/^<(.*)>(.*)<(.*)>/g){ print "<b>$1</b>"; print $2; print "<b>$3</b>"; }else{ print "$Nothing"; } }

Thank you!

In reply to Regular Expression 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.