Hi.  I'm not totally sure what ur asking but it seems that u want to do
variable substitution in an XML file.  If the variable names are already in
the text u need an eval.

$text = eval "\"$xmlfile\"";

That will replace $1 with whatever it's current value is.  However, this
isn't really the right way to substitute text.  

Another way: $xmlfile =~ s/\$1/$new/;   ## works with any token

If u can give a more generic description of what u have to do, maybe we can
help more.


At 06:58 PM 7/15/2009 +0530, Kprasad wrote:
>Here is the Perl code which I'm using for substitution in xml file
UIIE_A_123456.xml.
>I'm getting search string and replacement string for substitution from
another file (cleanup.txt)
>
>But after substitution, variable of replaced string doesn't interpolated as
defined in 'cleanup.txt' i.e., 
><!DOCTYPE $1 SYSTEM "http://cats.tfinforma.com/dtd/tfja/dtd/TFJA.dtd";>
>SHOULD BE
><!DOCTYPE article SYSTEM "http://cats.tfinforma.com/dtd/tfja/dtd/TFJA.dtd";>
>
>Perl Code:
>
>#!/usr/bin/perl -w -s
>
> $/ = undef;
> open(INFILE,"<c:/UIIE_A_123456.xml") or die "Cannot Open: xml";
> $_=<INFILE>;xml_cleanup();
> close(INFILE);
> open(OUTFILE,">c:/UIIE_A_123456") or die "Cannot Open: xml";
> print OUTFILE $_;
>
>
>sub xml_cleanup
>{
> open(IN,"<c:/cleanup.xml") or die "Cannot Open: cleanup.xml";
> $cleanup=<IN>;
> close(IN);
> while ($cleanup=~/<text>(.*?)<\/text><with>(.*?)<\/with>/gc)
> {
>  $txt="";
>  $rep="";
>  $txt=$1;$rep=$2;
>  if($_ =~ s/$txt/$rep/g){print "Replaced $txt with $rep\n";}
>  else{print "Not found $txt\n";}
> }
>}
>
>File: UIIE_A_123456.xml
><?xml version="1.0" encoding="utf-8"?>
><!DOCTYPE $1 SYSTEM "http://cats.tfinforma.com/dtd/tfja/dtd/TFJA.dtd";>




--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to