in reply to Re: Parsing command line
in thread Parsing command line

I did exactly the same as you, here is it:
local %hash; if (GetOptions(\%hash, 'pdcuse!', 'uamlist=s', 'loginmesg=s')) { &doSomething(); }
as you can see I used hash (reference), but doesn't supposed to matter (it happened to me even when I didn't used hash).

Hotshot

Replies are listed 'Best First'.
Re: Re: Re: Parsing command line
by Tomte (Priest) on Aug 26, 2002 at 13:29 UTC
    use Getopt::Long; use strict; use warnings; use Data::Dumper; my %hash; GetOptions(\%hash, 'pdcuse!', 'uamlist=s', 'loginmesg=s'); print "" . Dumper(\%hash) . "\n"; __END__ perl test.pl -u "test eins zwei drei" -l "test drei vier fuenf" -p yields: $VAR1 = { 'pdcuse' => 1, 'uamlist' => 'test eins zwei drei', 'loginmesg' => 'test drei vier fuenf' };

    using local instead of my doesn't alter the result, it simply works...(older SuSE, bah, perl 5.6.1)
    So I'm out of luck here...
    regards,
    tomte


      My fault, I wasn't clear enough. I wrote a command line interface to our product in my company. The parsing isn't working with spaces within it. from the Linux shell command line it works.
      Linux prompt>myprog Welcome to my program !!! myprog prompt> set -message "hello world" # this doesn't work
      I hope now the question is clearer.

      Hotshot
        I hope now the question is clearer.

        Not really ;-)
        is myprog a shell-script, that starts perl-programs or a perl-program internally using input via STDIN to feed Getopt::Long?

        I'm sorry to say, more than ever: without actual code with the right context, I for one can't help you any further,

        If it is a bash-script calling a perl-script, it's with a high probability a quoting-problem.
        regards,
        tomte