in reply to Re^4: Substitution for braces
in thread Substitution for braces

This seems to be a new problem, only partly related to your original post. I'm sorry, but I don't understand what your current problem is. Please provide a self-contained program and the input and output data, and what you expect. Please also put all your &, &amp; and &amp;amp; in between <code>...</code> tags, so we can understand when you mean & and when you mean &amp;.

Judging from your description, my imagination is that you want to replace &amp; with - except within <cc>...</cc> tags. If that's true, then regular expressions are the wrong tool for the general case, and you should use an XML parser like XML::LibXML or XML::Twig.

Replies are listed 'Best First'.
Re^6: Substitution for braces
by gem555 (Acolyte) on Jul 09, 2009 at 09:33 UTC
    #!/usr/bin/perl use strict; use warnings; my $filename = 'library.xml'; use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); #my $book; foreach my $title ($doc->findnodes('/library/book/title')) { my $name= $title->to_literal ; print $name; }
    Can I print just the title without giving "'/library/book/title'". There are many XML files and each have a different structure. How can I restrict to find the only the <cc> tag and get the value inside it.

      Potentially you want to learn about XPath. //cc will find all <cc> nodes, wherever they live.