chidori has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am using a perl script edit certain xml tags. Previously i was picking up the xml files one by one and running the code. But I thought it would be easy if i can edit all xml files in a single go.
Below is the part of my codeThe code seems to work. But i would like to know if there is a better way to do and also if there is any pitfall the way i do it now.#!/usr/bin/perl use Getopt::Long; use XML::Twig; foreach my $xml(@file) { $twig->parsefile_inplace($xml); } sub getoption{ GetOptions ("file=s" => \$data,) or die("Error in command line argumen +ts\n"); @file=glob($data); #globbing to pick '*.xml' }
Script calls
./script -f config.xml ./script -f '*.xml'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Editing multiple xml files in perl with help of Getopt::Long and Globbing
by hippo (Archbishop) on Nov 30, 2013 at 11:08 UTC | |
by Jim (Curate) on Nov 30, 2013 at 16:32 UTC | |
by chidori (Novice) on Nov 30, 2013 at 13:17 UTC |