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!

Replies are listed 'Best First'.
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 (Patriarch) 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.