in reply to XML::Twig parsing Problem

I'm afraid I don't have the solution to your problem, but you're more likely to get a useful response if you reformat your node some.

At the very least, pull your question and explanation out of the code tags and put them in paragraphs, and get rid of the double spacing.

for(split(" ","tsuJ rehtonA lreP rekcaH")){print reverse . " "}print "\b.\n";

Replies are listed 'Best First'.
Re^2: XML::Twig parsing Problem
by saurabh.x.pandey (Initiate) on Dec 02, 2008 at 11:34 UTC
    sub select_change { my($twig,$tag_name)=@_; if ($tag_name->att('$att_name') =~ "$att_value") { $tag_name->set_text('$tag_text'); } }
    Actually I have problem on one point. my($twig,$tag_name)=@_; the value of $tag_name=href so in place of $tag_name the value should be $href. for that I tried as my($twig,${$tag_name)}=@_; but it's not working...so what is the solution to do it.

      I don't quite understand the question, but the arguments to the handler are the twig itself and the element object, not its tag name. So if you want to change the name of the element, you need $tag->set_tag( ...).

      Also, the single quotes in '$tag_text' prevent interpolation (you will get the literal text $tag_text), get rid of them and you will get the value of $tag_text.

        HI Mirod actually $tag_name=href $tag_att=attr $att_value=cde $tag_text="the string which i want to write in place of old one" Here I want to rewrite in the file --the text of the tag which is href + and having attribute as "attr" value is "cde" and I want to relace t +his tag text with new "tag_text". there are two href tags in the file but i want to rewrite the text of +only href tag which has attr="cde" in the file. if i m using the original names in the program then it works but when +i m taking them as arguments then it's creating problem.