On Thu, 2 Aug 2001 09:35:27 -0400, Ronald J Kimball wrote:

>> NB: the goal is to strip "-x aaa" pairs off @ARGV, including the lone
>> "-x" at the end, and have the last "aaa" in $ext.

>Have you tried one of the Getopt modules, such as Getopt::Std or Getopt::Long?

Thank you for comments and tips. Being a beginner, I've never used libraries, but this 
is an opportunity to have a go at it.

It looks as if Getopt::Std would fit my case, but I haven't yet been able to call it 
from my script. I seem not to understand how to pass it arguments.

#!/usr/local/bin/perl -w
$_='mbx2 5 -x tonus -a -x';
$^O eq 'MacOS' && (@ARGV = split); # test mac/unix
print "A argv= @ARGV\n";
foreach (@INC) {print "C $_\n"}; #show library search
use Getopt::Std;
getopts 'ax:';
print "E argv= @ARGV\n";
print "opt_a=$opt_a\n";
print "opt_x=$opt_x\n";
__END__
# Name "main::opt_x" used only once: possible typo.
File 'PPC HD:Privat:MacPerl store:mini tests Ÿ:old:5-7'; Line 11
# Name "main::opt_a" used only once: possible typo.
File 'PPC HD:Privat:MacPerl store:mini tests Ÿ:old:5-7'; Line 10
A argv= mbx2 5 -x tonus -a -x
C PPC HD:Privat:MacPerl store:MacPerl versions:MacPerl 5.20r4 Ÿ:lib:MacPPC:
C PPC HD:Privat:MacPerl store:MacPerl versions:MacPerl 5.20r4 Ÿ:lib:
C PPC HD:Privat:MacPerl store:MacPerl versions:MacPerl 5.20r4 Ÿ:lib:MacPPC:
C PPC HD:Privat:MacPerl store:MacPerl versions:MacPerl 5.20r4 Ÿ:lib:
C :
C Dev:Pseudo:
E argv= mbx2 5 -x tonus -a -x
# Use of uninitialized value.
File 'PPC HD:Privat:MacPerl store:mini tests Ÿ:old:5-7'; Line 10
opt_a=
# Use of uninitialized value.
File 'PPC HD:Privat:MacPerl store:mini tests Ÿ:old:5-7'; Line 11
opt_x=

Reply via email to