Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Editing multiple xml files in perl with help of Getopt::Long and Globbing

by hippo (Prior)
on Nov 30, 2013 at 11:08 UTC ( #1065046=note: print w/ replies, xml ) Need Help??


in reply to Editing multiple xml files in perl with help of Getopt::Long and Globbing

Unless you are doing something else with other options to the script which you aren't showing us, I don't see any reason for you to do the globbing in the script. Why not just use the shell's globbing instead? If you invoke the script with:

./script *.xml

and handle this in your code with:

while (my $file = shift @ARGV) { next unless -r $file; # Process the file here }

would that not achieve the end result?

Replies are listed 'Best First'.
Re^2: Editing multiple xml files in perl with help of Getopt::Long and Globbing
by Jim (Curate) on Nov 30, 2013 at 16:32 UTC

    Shell globbing isn't universal or portable. So in many cases, it's appropriate to expand globs within the Perl script using File::Glob or other mechanism. For example, in the Microsoft Windows shell (Command Prompt), wildcards are not as powerful or as useful as BSD-style globs; in particular, they can't be used to expand directories (folder), which makes them generally useless for my purposes. I invariably need my Perl scripts to permit their users to glob multiple folder names.

Re^2: Editing multiple xml files in perl with help of Getopt::Long and Globbing
by chidori (Novice) on Nov 30, 2013 at 13:17 UTC
    Sorry , didn't mention in my intial post. Yes, i have other options that will get the date and another option to print the xml content. Thats why i didn't do shell globbing.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2016-08-25 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (363 votes). Check out past polls.