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

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


Replies are listed 'Best First'.
Re: RE(5): Parsing command line
by hotshot (Prior) on Aug 26, 2002 at 14:12 UTC
    sorry again, myprog is a perl script that starts ap perl program using input via STDIN as you said.
    here is some more code:
    # main perl script my $input; # defining ReadLine module for supporting my $term = new Term::ReadLine 'Command Line Interface'; print "\nWelcome to my command line interface (version $version)!\n\n" +; while (defined($input = $term->readline("\n" . $prompt.' (main, exit, +back, help) > '))) { chomp $input; $input =~ s/^\s+//; # delete leading spaces $input =~ s/\s+$//; # delete trailing spaces &parseCmdLine(); ... } sub parseCmdLine { ... local %hash; if (GetOptions(\%hash, 'netbios=s', 'winbind!', 'srvstring=s')) { &doSomething(); } ... }


    Hotshot
      Ok, I assume I got you wrong again...;-)

      I figured you have to overwrite @ARGV to get GetOptions to work with you local data. I played a bit with the possibility to turn $input into an array. Unfortunatly I have a meeting right now, I'll get back to it this evening, if you still need help then...

      regards,
      tomte
        I do overwrite @ARGV, I guess I missed that in my 'cut & paste':
        @ARGV = split(' ', $input);
        I have this row just before the call to parseCmdLine().

        Hotshot