mam i used you code for replace an xml file tags against a configuration file

_INPUT XML FILE_ <?xml version="1.0"?> <book> <chapter chapnum="12" id="c012"> <title>12 Other Interneuronal Signals</title> <para>The previous chapters were devoted to what we might now consider + the <c>&#8220;</c>classical<c>&#8221;</c> or perhaps <c>&#8220;</c>c +onventional<c>&#8221;</c> neurotransmitters. By this, we mean those t +ransmitters that are synthesized within the neuron (cell body or syna +ptic terminal) that releases them by activity-dependent, Ca<hotlink>< +xref xref="r012002" xidtype="text"/><sup>2<c>+</c></sup></hotlink>-de +pendent mechanisms to act on discrete receptors largely, but not excl +usively, on the neuron, smooth muscle, or gland cell opposite the ner +ve terminal. However, as the wheels of progress have turned, it seems + that once again the more we learn about inter-cellular communication + in the nervous system, the more complicated the situation becomes. T +he purine signals discussed in <hotlink><xref xref="c011" xidtype="te +xt"/>Chapter 11</hotlink> provided an appetizer by acting both pre- a +nd postsynaptically, as do many of the other classical transmitters. +Nevertheless, through improved methods of substance identification an +d detection of signal responsiveness, several potent interneuronal si +gnals have been recognized that are not stored in vesicles, or even s +tored at all, but rather seem to be synthesized and released on deman +d to act more broadly than the immediate-releasing neuron terminals a +nd to modify the effectiveness of the conventional interneuronal sign +als.</para> <subchap1><head1>Prostaglandins</head1> <para>The prostaglandins are a group of biologically active derivative +s of arachidonic acid often referred to as eicosanoids for their basi +c 20-carbon atom structure. The two major pathways of eicosanoid meta +bolism are the cyclooxygenase pathway, which yields the prostaglandin +s and thromboxanes, and the lipoxygenase pathway, which yields the le +ukotrienes. A minor pathway termed epoxy-genase yields epoxides, whic +h have received scant attention in the central nervous system (CNS). +Arachidonic acid is synthesized on demand from dietary linoleic acid +by either a G protein-regulated phospholipase A<sub>2</sub> or diglyc +eride lipase activation (<hotlink><xref xref="f012001" xidtype="figur +e"/>Fig. 12&#8211;1</hotlink>), and it yields a very broad array of b +ioactive metabolites, as shown in <hotlink><xref xref="f012002" xidty +pe="figure"/>Figure 12&#8211;2</hotlink>. The three major groups of a +rachidonic acid-derived metabolites are the prostaglandins, thromboxa +nes, and leukotrienes.</para> <para>Historically, the earliest effect of prostaglandins arose with t +he recognition in the 1930s that fresh semen could induce contraction + of myometrial muscle, and the name arose from the factor<c>&#39;</c> +s anticipated origin. As chemical detection methods improved in the 1 +950s, two classes of prostaglandins were recognized<c>&#8212;</c>a PG +E class that was soluble in ether and a PGF class soluble in phosphat +e buffer (<emphasis style="it">fosfat</emphasis> in Swedish)<c>&#8212 +;</c>and one of their sites of synthesis localized to seminal vesicle +s. Subsequent work indicated that virtually every organ could manufac +ture prostaglandins, and several distinct synthetic pathways were rec +ognized. A major advancement occurred when John Vane proposed that as +pirin and several other nonsteroidal anti-inflammatory drugs (NSAIDs) + worked by inhibiting the prostaglandin-synthesizing enzyme cyclooxyg +enase. Work in the 1990s revealed that a second cyclooxygenase (COX-2 +) (and perhaps a third) was also present in the CNS. Since this enzym +e was shown to be induced by inflammatory cytokines, it immediately s +uggested a separate target for relief of inflammatory pain, with the +potential for reduced symptoms from the gastrointestinal tract irrita +tion typically evoked by NSAIDs. COX-2 is also induced <emphasis styl +e="it">in vitro</emphasis> by the neurotransmitter GLU and inhibited +by glucocorticoids. Unfortunately, prolonged use of COX-2 inhibitors +has untoward cardiovascular side effects, leading to multiple litigio +us claims and diverting attention from this once-promising therapeuti +c modification.</para> <para>It is well known that the eicosanoids, particularly the prostagl +andin series, play an important modulatory role in nervous tissue, bu +t it has been difficult to write a lucid account of specifically how +and where they act. This is primarily due to the fact that they are n +ot stored in tissues, nervous or other, but synthesized on demand, pa +rticularly in pathophysiological conditions. They act briefly (some w +ith a half-life of seconds) and at extremely low concentrations (10&# +8722;<hotlink><xref xref="r012010" xidtype="text"/><sup>10</sup></hot +link> M). Although indomethacin is a good inhibitor of cyclooxygenase +-1, blocking the conversion of arachidonic acid to prostaglandins, th +ere are few specific inhibitors available to block lipoxygenase and e +poxygenase. Thus, although it had been postulated that the E series o +f prostaglandins modulates noradrenergic release, blocks the convulsa +nt activity of pentylenetetrazol, strychnine, and picrotoxin (possibl +y by increasing the level of <c>&#947;</c>-aminobutyric acid <c>[</c> +GABA<c>]</c> in the brain), and increases the level of cAMP in cortic +al and hypothalamic slices, these effects were noted <emphasis style= +"it">in vitro</emphasis> with the addition of substantial amounts of +the prostaglandins. There was very little evidence in intact animals +to support these neuronal findings. Since we skeptics all hold <c>&#8 +220;</c><emphasis style="it">in vivo</emphasis> veritas<c>&#8221;</c> + in higher regard, the physiological relevance of the effect was in d +oubt.</para> <para>Subsequently, however, direct evidence has established arachidon +ic acid and lipoxygenases as second messengers. The cascade begins wi +th the binding of a neuroactive agent to its receptor. Then, accordin +g to findings from the Axelrod laboratory, the receptor is coupled to + G proteins, which may either activate or inhibit phospholipase A<sub +>2</sub>, although this has not been conclusively established for all + neural tissues. The activated enzyme promotes the release of arachid +onic acid, which will then act intracellularly as a second messenger. + Arachidonic acid and its metabolites can also leave the cell to act +extracellularly as first messengers on neighboring cells. Eicosanoids + have been shown to mediate the somatostatin-induced opening of an M +channel in hippocampal pyramidal cells and the release of VIP in mous +e cerebral cortical slices. At the supracellular level, prostaglandin +s of the E series have been held to be a mediator of fever and prosta +glandins of the D series as regulators of sleep. It is thus becoming +clear, despite enormous technological difficulties in assaying eicosa +noids, that these agents are major messengers.</para> <para>Another exciting chapter of the arachidonic acid story has been +told separately, namely the endocannabinoids, which are described lat +er in this chapter.</para></subchap1> <subchap1><head1>Neurosteroids</head1> <para>According to their discoverer, Etienne Baulieu, neurosteroids ar +e those steroids that are synthesized in the nervous system either <e +mphasis style="it">de novo</emphasis> from cholesterol or by <emphasi +s style="it">in situ</emphasis> metabolism of blood-borne precursors +but are found at levels in the nervous system that are independent of + steroid synthesis by adrenals or gonads. Such steroids include at le +ast two previously known steroid precursors, pregnenalone (PREG) and +dehydroepiandrosterone (DHEA), that in the nervous system have effect +s alone or as sulfated esters. In the central and peripheral nervous +systems, neurosteroid synthesis has been attributed to oligodendrocyt +es, astrocytes, and neurons. The peripheral benzodiazepine receptor f +ound on the mitochondrial outer membrane has been suggested to allow +cholesterol access to the P450 cleavage enzyme complex on the inner m +itochondrial membrane, leading to PREG formation and subsequently to +other neurosteroids (<hotlink><xref xref="f012003" xidtype="figure"/> +Fig. 12&#8211;3</hotlink>).</para> <para>In contrast to the endocrine actions of adrenal steroids on the +brain, acting at a distance and at very low concentrations, neuroster +oids are thought to act locally as either autocrine (acting on the ce +lls that synthesizes them) or paracrine (acting on cells close to the + site of synthesis) signals. In this manner, the ability to activate +myelin synthesis in oligodendrocytes may provide a reparative effect +in multiple sclerosis. In their sulfated ester forms, both PREG and D +HEA have been reported to be potent regulators of GABA<sub>A</sub> an +d NMDA receptor functions, with PREG-S and DHEA-S inhibiting the effe +cts of GABA; however, these effects on the GABA receptor are reduced +if the complex contains a <c>&#948;</c> subunit.</para> <para>In addition, further characterization of the neurosteroids sugge +sts that a small group of pregnenolone-, progesterone-, or tetrahydro +deoxycorticosterone-derived catabolites are the active moieties in th +e CNS, namely 3<c>&#945;</c>,5<c>&#945;</c>- and 3<c>&#945;</c>,5<c>& +#946;</c>-androsterone, 3<c>&#945;</c>,5<c>&#946;</c>-THP pregnenolon +e, 3<c>&#945;</c>,5<c>&#945;</c>-THP allopregnenolone, 3<c>&#945;</c> +,5<c>&#945;</c>-THDOC allotetrahydroDOC, 3<c>&#945;</c>,5<c>&#946;</c +>-THDOC tetrahydroDOC, and 3<c>&#945;</c>,5<c>&#945;</c>- and 3<c>&#9 +45;</c>,5<c>&#946;</c>-androstanol (Morrow, 2007). These are the neur +osteroids that are believed to be responsible for the largely GABA-en +hancing actions to induce anxiolytic, sedative, and anticonvulsant ac +tivity through allosteric modifications at discrete sites on the rece +ptor. Of interest is that systemic doses of ethanol at low to moderat +e pharmacological levels induce elevation of neurosteroids to levels +capable of modifying GABA receptors and contributing to the cellular +and behavioral effects of ethanol (see <hotlink><xref xref="c018" xid +type="text"/>Chapter 18</hotlink>).</para></subchap1> </chapter> </book> _CONFIGURATION FILE_ [chapter=section]||[para=p]||[/para]||[subchap1=subsec1]||[head1=h1]|| +[/head1]||[para=p]||[c=cha]||[/c]||[/para]||[/subchap1]||[/chapter]|| +[chapnum=secnum]||[title=head]||[/title]||[id=cid]||[/id] ||[/chapnum +] _CODE_ #!/usr/bin/perl use warnings; use strict; use Data::Dumper; use XML::Simple; my %xhash=(); my $file= $ARGV[0]; my $simple = XML::Simple->new(ForceArray => 1,KeepRoot => 1); my $xhash = $simple->XMLin($file); print Dumper ($xhash); open FH,"sampleconfg.ini" or die $!; my $line; my %c_hash=(); my $c_hashRef = ''; my @tmpA = (); #sub recur($); foreach $line (<FH>){ $line=~s/^(\s+)(.*)/$2/i; $line=~s/(.*?)(\s+)$/$2/i; chomp($line); if ($line ne ''){ $_=$line; $c_hashRef = ''; my @array = split(m/\|\|/, $line); # print @array; # exit; ($c_hashRef,@tmpA) = recur(\@array); # print Dumper($c_hashRef); } } print Dumper($c_hashRef); my %repl; # lookup table: a => 1, etc. traverse($c_hashRef, sub { my ($key, $val) = @_; $repl{$key} = $val; }, "collect" ); # print Dumper \%repl; # debug traverse($xhash, sub { my ($key, $val, $href) = @_; if (exists $repl{$key}) { my $newkey = $repl{$key}; $href->{$newkey} = $val; delete $href->{$key}; } }, "replace" ); print Dumper ($xhash); $simple->XMLout($xhash, KeepRoot => 1, OutputFile => 'pets.fixed.xml', XMLDecl => "<?xml version='1.0'?>", ); print "process over"; sub traverse { my ($hash, $callback, $mode) = @_; traverse($hash->[0], $callback, $mode) if ref($hash) eq "ARRAY"; return unless ref($hash) eq "HASH"; for my $key (keys %$hash) { my $val = $hash->{$key}; if (ref($val)) { traverse($val, $callback, $mode); if ($mode eq "collect") { if (exists $val->{repval}) { $callback->($key, $val->{repval}); } } } if ($mode eq "replace") { $callback->($key, $val, $hash); } } } sub recur($) { my $arrRef = $_[0]; my @procArr = @$arrRef; my $assign = ''; my %c_hash = (); my @tmpArr = @procArr; shift(@tmpArr); my $arr = $procArr[0]; if ($arr=~m/\[(.*?)\=(.*)\]/ig) { $assign = $1; my $tmpVal = ''; $tmpVal = $2; $tmpVal =~ s/\=(.*?)/$1/ig; $c_hash{$assign}{'repval'} = $tmpVal; ($c_hash{$assign}{'addval'},@tmpArr) = recur(\@tmpArr); $arr = shift(@tmpArr); if ($arr) { if ($arr=~m/\[(.*?)\=(.*)\]/ig) { my $key = $1; my $tmpVal = ''; $tmpVal = $2; $tmpVal =~ s/\=(.*?)/$1/ig; $c_hash{$key}{'repval'} = $tmpVal; ($c_hash{$key}{'addval'},@tmpArr) = recur(\@tmpArr +); $arr = shift(@tmpArr); } } } return (\%c_hash, @tmpArr); } _OUTPUT XML FILE_ <?xml version='1.0'?> <book> <section name="c012" secnum="12"> <head>12 Other Interneuronal Signals</head> <p> <cha>“</cha> <cha>”</cha> <cha>“</cha> <cha>”</cha> <content>The previous chapters were devoted to what we might now + consider the </content> <content>classical</content> <content> or perhaps </content> <content>conventional</content> <content> neurotransmitters. By this, we mean those transmitters + that are synthesized within the neuron (cell body or synaptic termin +al) that releases them by activity-dependent, Ca</content> <content>-dependent mechanisms to act on discrete receptors larg +ely, but not exclusively, on the neuron, smooth muscle, or gland cell + opposite the nerve terminal. However, as the wheels of progress have + turned, it seems that once again the more we learn about inter-cellu +lar communication in the nervous system, the more complicated the sit +uation becomes. The purine signals discussed in </content> <content> provided an appetizer by acting both pre- and postsyna +ptically, as do many of the other classical transmitters. Nevertheles +s, through improved methods of substance identification and detection + of signal responsiveness, several potent interneuronal signals have +been recognized that are not stored in vesicles, or even stored at al +l, but rather seem to be synthesized and released on demand to act mo +re broadly than the immediate-releasing neuron terminals and to modif +y the effectiveness of the conventional interneuronal signals.</conte +nt> <hotlink> <sup>2<cha>+</cha> </sup> <xref xidtype="text" xref="r012002" /> </hotlink> <hotlink>Chapter 11<xref xidtype="text" xref="c011" /> </hotlink> </p> <subsec1> <h1>Prostaglandins</h1> <p> <content>The prostaglandins are a group of biologically active + derivatives of arachidonic acid often referred to as eicosanoids for + their basic 20-carbon atom structure. The two major pathways of eico +sanoid metabolism are the cyclooxygenase pathway, which yields the pr +ostaglandins and thromboxanes, and the lipoxygenase pathway, which yi +elds the leukotrienes. A minor pathway termed epoxy-genase yields epo +xides, which have received scant attention in the central nervous sys +tem (CNS). Arachidonic acid is synthesized on demand from dietary lin +oleic acid by either a G protein-regulated phospholipase A</content> <content> or diglyceride lipase activation (</content> <content>), and it yields a very broad array of bioactive meta +bolites, as shown in </content> <content>. The three major groups of arachidonic acid-derived +metabolites are the prostaglandins, thromboxanes, and leukotrienes.</ +content> <hotlink>Fig. 12–1<xref xidtype="figure" xref="f012001" /> </hotlink> <hotlink>Figure 12–2<xref xidtype="figure" xref="f012002" /> </hotlink> <sub>2</sub> </p> <p> <c>'</c> <c>—</c> <c>—</c> <content>Historically, the earliest effect of prostaglandins a +rose with the recognition in the 1930s that fresh semen could induce +contraction of myometrial muscle, and the name arose from the factor< +/content> <content>s anticipated origin. As chemical detection methods i +mproved in the 1950s, two classes of prostaglandins were recognized</ +content> <content>a PGE class that was soluble in ether and a PGF class + soluble in phosphate buffer (</content> <content> in Swedish)</content> <content>and one of their sites of synthesis localized to semi +nal vesicles. Subsequent work indicated that virtually every organ co +uld manufacture prostaglandins, and several distinct synthetic pathwa +ys were recognized. A major advancement occurred when John Vane propo +sed that aspirin and several other nonsteroidal anti-inflammatory dru +gs (NSAIDs) worked by inhibiting the prostaglandin-synthesizing enzym +e cyclooxygenase. Work in the 1990s revealed that a second cyclooxyge +nase (COX-2) (and perhaps a third) was also present in the CNS. Since + this enzyme was shown to be induced by inflammatory cytokines, it im +mediately suggested a separate target for relief of inflammatory pain +, with the potential for reduced symptoms from the gastrointestinal t +ract irritation typically evoked by NSAIDs. COX-2 is also induced </c +ontent> <content> by the neurotransmitter GLU and inhibited by glucoco +rticoids. Unfortunately, prolonged use of COX-2 inhibitors has untowa +rd cardiovascular side effects, leading to multiple litigious claims +and diverting attention from this once-promising therapeutic modifica +tion.</content> <emphasis style="it">fosfat</emphasis> <emphasis style="it">in vitro</emphasis> </p> <p> <c>γ</c> <c>[</c> <c>]</c> <c>“</c> <c>”</c> <content>It is well known that the eicosanoids, particularly t +he prostaglandin series, play an important modulatory role in nervous + tissue, but it has been difficult to write a lucid account of specif +ically how and where they act. This is primarily due to the fact that + they are not stored in tissues, nervous or other, but synthesized on + demand, particularly in pathophysiological conditions. They act brie +fly (some with a half-life of seconds) and at extremely low concentra +tions (10−</content> <content> M). Although indomethacin is a good inhibitor of cyc +looxygenase-1, blocking the conversion of arachidonic acid to prostag +landins, there are few specific inhibitors available to block lipoxyg +enase and epoxygenase. Thus, although it had been postulated that the + E series of prostaglandins modulates noradrenergic release, blocks t +he convulsant activity of pentylenetetrazol, strychnine, and picrotox +in (possibly by increasing the level of </content> <content>-aminobutyric acid </content> <content>GABA</content> <content> in the brain), and increases the level of cAMP in co +rtical and hypothalamic slices, these effects were noted </content> <content> with the addition of substantial amounts of the pros +taglandins. There was very little evidence in intact animals to suppo +rt these neuronal findings. Since we skeptics all hold </content> <content> veritas</content> <content> in higher regard, the physiological relevance of the + effect was in doubt.</content> <emphasis style="it">in vitro</emphasis> <emphasis style="it">in vivo</emphasis> <hotlink> <sup>10</sup> <xref xidtype="text" xref="r012010" /> </hotlink> </p> <p> <content>Subsequently, however, direct evidence has establishe +d arachidonic acid and lipoxygenases as second messengers. The cascad +e begins with the binding of a neuroactive agent to its receptor. The +n, according to findings from the Axelrod laboratory, the receptor is + coupled to G proteins, which may either activate or inhibit phosphol +ipase A</content> <content>, although this has not been conclusively established + for all neural tissues. The activated enzyme promotes the release of + arachidonic acid, which will then act intracellularly as a second me +ssenger. Arachidonic acid and its metabolites can also leave the cell + to act extracellularly as first messengers on neighboring cells. Eic +osanoids have been shown to mediate the somatostatin-induced opening +of an M channel in hippocampal pyramidal cells and the release of VIP + in mouse cerebral cortical slices. At the supracellular level, prost +aglandins of the E series have been held to be a mediator of fever an +d prostaglandins of the D series as regulators of sleep. It is thus b +ecoming clear, despite enormous technological difficulties in assayin +g eicosanoids, that these agents are major messengers.</content> <sub>2</sub> </p> <p>Another exciting chapter of the arachidonic acid story has be +en told separately, namely the endocannabinoids, which are described +later in this chapter.</p> </subsec1> <subsec1> <head1>Neurosteroids</head1> <para> <content>According to their discoverer, Etienne Baulieu, neuro +steroids are those steroids that are synthesized in the nervous syste +m either </content> <content> from cholesterol or by </content> <content> metabolism of blood-borne precursors but are found a +t levels in the nervous system that are independent of steroid synthe +sis by adrenals or gonads. Such steroids include at least two previou +sly known steroid precursors, pregnenalone (PREG) and dehydroepiandro +sterone (DHEA), that in the nervous system have effects alone or as s +ulfated esters. In the central and peripheral nervous systems, neuros +teroid synthesis has been attributed to oligodendrocytes, astrocytes, + and neurons. The peripheral benzodiazepine receptor found on the mit +ochondrial outer membrane has been suggested to allow cholesterol acc +ess to the P450 cleavage enzyme complex on the inner mitochondrial me +mbrane, leading to PREG formation and subsequently to other neuroster +oids (</content> <content>).</content> <emphasis style="it">de novo</emphasis> <emphasis style="it">in situ</emphasis> <hotlink>Fig. 12–3<xref xidtype="figure" xref="f012003" /> </hotlink> </para> <para> <c>δ</c> <content>In contrast to the endocrine actions of adrenal stero +ids on the brain, acting at a distance and at very low concentrations +, neurosteroids are thought to act locally as either autocrine (actin +g on the cells that synthesizes them) or paracrine (acting on cells c +lose to the site of synthesis) signals. In this manner, the ability t +o activate myelin synthesis in oligodendrocytes may provide a reparat +ive effect in multiple sclerosis. In their sulfated ester forms, both + PREG and DHEA have been reported to be potent regulators of GABA</co +ntent> <content> and NMDA receptor functions, with PREG-S and DHEA-S +inhibiting the effects of GABA; however, these effects on the GABA re +ceptor are reduced if the complex contains a </content> <content> subunit.</content> <sub>A</sub> </para> <para> <c>α</c> <c>α</c> <c>α</c> <c>β</c> <c>α</c> <c>β</c> <c>α</c> <c>α</c> <c>α</c> <c>α</c> <c>α</c> <c>β</c> <c>α</c> <c>α</c> <c>α</c> <c>β</c> <content>In addition, further characterization of the neuroste +roids suggests that a small group of pregnenolone-, progesterone-, or + tetrahydrodeoxycorticosterone-derived catabolites are the active moi +eties in the CNS, namely 3</content> <content>,5</content> <content>- and 3</content> <content>,5</content> <content>-androsterone, 3</content> <content>,5</content> <content>-THP pregnenolone, 3</content> <content>,5</content> <content>-THP allopregnenolone, 3</content> <content>,5</content> <content>-THDOC allotetrahydroDOC, 3</content> <content>,5</content> <content>-THDOC tetrahydroDOC, and 3</content> <content>,5</content> <content>- and 3</content> <content>,5</content> <content>-androstanol (Morrow, 2007). These are the neurostero +ids that are believed to be responsible for the largely GABA-enhancin +g actions to induce anxiolytic, sedative, and anticonvulsant activity + through allosteric modifications at discrete sites on the receptor. +Of interest is that systemic doses of ethanol at low to moderate phar +macological levels induce elevation of neurosteroids to levels capabl +e of modifying GABA receptors and contributing to the cellular and be +havioral effects of ethanol (see </content> <content>).</content> <hotlink>Chapter 18<xref xidtype="text" xref="c018" /> </hotlink> </para> </subsec1> </section> </book>

see the output first subchap1 group only replaced next subchap1 is not replaced why like this please help me to debug this code


In reply to Re^2: update required for subroutine by satzbu
in thread update required for subroutine by satzbu

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.