in reply to parsing arguments

The solution provided in this reply does not fit your needs, but it is still worth to mention, as it works for data that is slightly more restricted than yours.

The idea is to quickly form a xml string, and simply utilize XML::Simple or any other XML parser to parse it. In this way, you don't need to duplicate what others already did for you.

use strict; use warnings; use XML::Simple; use Data::Dumper; my $str = "lexwhere=\"'in('DIS', 'DIM', 'DIR')'\" title=\"'this is a t +itle'\""; my $str_xml = "<str " . $str . " />"; print $str_xml, "\n"; my $ref = XMLin($str_xml); print Dumper($ref);

Replies are listed 'Best First'.
Re: Re: parsing arguments
by zakzebrowski (Curate) on Oct 08, 2003 at 01:16 UTC
    I was going to suggest Config::IniFiles myself...
    use Config::IniFiles; my $config = Config::IniFiles->new(file=>'asdf.ini'); my $someParam = $config->val('section','param');
    where asdf.config would look like
    [section] param=value


    ----
    Zak
    undef$/;$mmm="J\nutsu\nutss\nuts\nutst\nuts A\nutsn\nutso\nutst\nutsh\ +nutse\nutsr\nuts P\nutse\nutsr\nutsl\nuts H\nutsa\nutsc\nutsk\nutse\n +utsr\nuts";open($DOH,"<",\$mmm);$_=$forbbiden=<$DOH>;s/\nuts//g;print +;

      I'm not too familiar with Config::Inifiles, but from your example, it doesn't seem to fit mifflin's needs, since (s)he wants to parse command line arguments, and Config::Inifiles works with, *tada* Inifiles :-)

      Since the Getopt::Long was already mentioned, I'd like to add "AppConfig". I have been using that myself recently and must say it works nice. It parses command line arguments, aswell as configuration files.

      --
      B10m

      Edit: English can be hard sometimes :-(
        Indeed, you are correct. However, in the spirit of "there's more than one way to do it", I provided the link to the module... Cheers


        ----
        Zak
        undef$/;$mmm="J\nutsu\nutss\nuts\nutst\nuts A\nutsn\nutso\nutst\nutsh\ +nutse\nutsr\nuts P\nutse\nutsr\nutsl\nuts H\nutsa\nutsc\nutsk\nutse\n +utsr\nuts";open($DOH,"<",\$mmm);$_=$forbbiden=<$DOH>;s/\nuts//g;print +;