on-internet
← Community

Getopt::Long multiple arguments with optional parameter

Stack Overflow ·

I'm trying to solve this scenario with Getopt::Long. ./myscript -m /abc -m /bcd -t nfs -m /ecd -t nfs ... -m is mount point and -t is type of file system (can be placed, but it is not mandatory). Getopt::Long::Configure("bundling"); GetOptions('m:s@' => \$mount, 'mountpoint:s@' => \$mount, 't:s@' => \$fstype, 'fstype:s@' => \$fstype) This is not right. I'm not able pair proper mount and fstype: ./check_mount.pl -m /abc -m /bcd -t nfs -m /ecd -t nfs $VAR1 = [ '/abc', '/bcd', '/ecd' ]; $VAR1 = [ 'nfs', 'nfs' ]; I need to fill unspecified fstype, e.g., with "undef" value. The best solution for me

Comments

Sign in or sign up to comment and upvote.

No comments yet.