Guest User

Untitled

a guest
Sep 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. How to get all options from Getopt Long without specifc knowledge of the params?
  2. use Getopt::Long qw(GetOptionsFromArray);
  3.  
  4. my %options;
  5.  
  6. my @opt_spec = qw(a:s b:s c:s d:s e:s f:s g:s h:s i:s j:s k:s l:s m:s n:s o:s p:s r:s q:s r:s s:s t:s u:s v:s w:s x:s y:s z:s);
  7.  
  8. Getopt::Long::GetOptions(%options, @opt_spec);
  9.  
  10. -a=-b -c -d -e -f g --h -- -i -j
  11.  
  12. my %options = (
  13. 'a' => '-b',
  14. 'c' => '',
  15. 'd' => '',
  16. 'e' => '',
  17. 'f' => 'g'
  18. 'h' => '',
  19. );
  20. @ARGV = (
  21. '-i',
  22. '-j',
  23. );
  24.  
  25. my %options = (
  26. 'a' => '-b',
  27. 'c' => '-d',
  28. 'e' => '-f',
  29. 'h' => '--',
  30. 'i' => '-j'
  31. );
  32. @ARGV = (
  33. 'g',
  34. );
  35.  
  36. my @opt_spec = map "$_:s", 'a'..'z';
Add Comment
Please, Sign In to add comment