Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Passing Parameters in XML::Simple

by PerlScholar (Acolyte)
on Oct 06, 2010 at 08:18 UTC ( #863735=perlquestion: print w/ replies, xml ) Need Help??
PerlScholar has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

Iím using XML simple for my config and normally you would declare the config path as below:

use strict;
use XML::Simple;

my $config = XMLin(ĎmyConfig.xmlí);

Is there a way of passing the config as a parameter to be entered at the command line? I was thinking something like the code below but it didnít seem to work.

my $config = XMLin($ARGV[0]);

Would appreciate any help. Many thanks!

Comment on Passing Parameters in XML::Simple
Select or Download Code
Re: Passing Parameters in XML::Simple
by Anonymous Monk on Oct 06, 2010 at 09:15 UTC
    normally you would declare the config path as below:...

    Not with those angled quotes you wouldn't, you need regular quotes :)

    Is there a way of passing the config as a parameter to be entered at the command line?

    $ perl -le" print for @ARGV" "a b c" 1 2 3 a b c 1 2 3 $
    See perlrun, Behind the GUI lives the Shell
Re: Passing Parameters in XML::Simple
by ikegami (Pope) on Oct 06, 2010 at 16:20 UTC
    my $config = XMLin($ARGV[0]); is correct. It will use the first argument passed to the script, assuming @ARGV hasn't been modified.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2014-12-28 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls