Unlike the other folks who replied above, I tried to extract the seem to be replying to a version of the OP that contains perl code and data that you attempted to include in your post.

First: Please update your post and place "code" tags around your sample data and code snippet, like this:

<code> <- you need to type in these tags exactly as shown # xml data: <gname>abc</gname> <-- then you can type these exactly as shown. <pname>xyz</pname> # html data: <p>ABC</p> <p><i>xyz</i></p> </code>
and like this:
<code> open(F2,"<F2>"); my $xml_list1="(.*)\.html"; # here the data enclosed inside the parentheses also appears when # printed. I want say the file name is "abc.html" so i want to keep # "abc" as interchangeable, so that i dont need to write/modify the # code if any filename other than abc.html occurs. close F2; #print $xml_list1."\n"; foreach my $f (@filenames) { #print $f."\n"; open(F1,"<F1>"); my $data=join("",<F1>); close F1; my $filename=substr($f,0,index($f,'.')); my $xml_list=$filename.".xml"; while($xml_list=~m//ig) # the code doesn't enter the while/if loop, seems that it finds some # error in reading the filename $xml_list, but i tried using # $xml_list1 too... but still the loop doesnt work. </code>
Now that your data and snippet are more visible to people, I would say that there's still not enough for us to work with. Your sample data is too sparse, the code incomplete and makes no sense, and you don't give a clear explanation of what you're actually trying to accomplish. What should your script produce as output?

You might want to look at this code I posted a while ago, for using XPath expressions on a command line to extract portions of XML: Re: XPath command line utility... -- it might give you a starting point for extracting "gname/pname" elements from your xml file, and might work on the html data also.


In reply to Re: How to compare the data of two files (.xml and .html) using perl(regex)? by graff
in thread How to compare the data of two files (.xml and .html) using perl(regex)? by flora

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.