Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Modidy XML contents

by gvinu4u (Acolyte)
on Jun 16, 2012 at 18:06 UTC ( #976584=perlquestion: print w/ replies, xml ) Need Help??
gvinu4u has asked for the wisdom of the Perl Monks concerning the following question:

I am reading the file names and want to insert the file name and count into the xml, I'm unable to perform this, can any one please help me in this below piece of code

#! /usr/bin/perl use XML::Simple; use Data::Dumper; $dir = "C:/Guru/Apollo/Video/VC1/"; $count = 0; opendir(BIN, $dir) or die "Can't open $dir: $!"; my @files = glob("C:/Guru/Apollo/Video/VC1/*"); foreach(@files) { print "\n",$_,"\n"; $count++; my $xml = q~<TEST testId="$count"> <InputFile CopyFile="true" DeleteLocalFile="true">$_</ +InputFile> <PlaybackActions> <Start> <DumpTopology></DumpTopology> </Start> <MonitorPipeline> <Duration>-1</Duration> </MonitorPipeline> <Close> </Close> </PlaybackActions> </TEST>~; print $xml,$/; }

Comment on Modidy XML contents
Download Code
Re: Modidy XML contents
by roboticus (Canon) on Jun 16, 2012 at 20:55 UTC

    gvinu4u:

    Try using the qq operator instead of the q operator.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Modify XML contents
by kcott (Abbot) on Jun 17, 2012 at 06:25 UTC

    ++roboticus' solution should fix your immediate problem. You might consider a here document as a more readable alternative.

    my $xml = << "END_OF_XML"; <TEST testID="$count"> <InputFile CopyFile="true" DeleteLocalFile="true">$_</InputFile> <PlaybackActions> <Start> <DumpTopology></DumpTopology> </Start> <MonitorPipeline> <Duration>-1</Duration> </MonitorPipeline> <Close> </Close> </PlaybackActions> </TEST> END_OF_XML print $xml;

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://976584]
Approved by philipbailey
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-09-19 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (132 votes), past polls