antsusage.pl
changeset 10 3dfa16523886
parent 4 ff72b00b4342
child 15 ebd8a4ddd7f2
equal deleted inserted replaced
9:1a7983cbb82a 10:3dfa16523886
     1 #/usr/bin/perl
     1 #/usr/bin/perl
     2 #======================================================================
     2 #======================================================================
     3 #                    A N T S U S A G E . P L 
     3 #                    A N T S U S A G E . P L 
     4 #                    doc: Fri Jun 19 13:43:05 1998
     4 #                    doc: Fri Jun 19 13:43:05 1998
     5 #                    dlm: Tue Apr  2 22:26:55 2013
     5 #                    dlm: Sat Jan 31 15:49:23 2015
     6 #                    (c) 1998 A.M. Thurnherr
     6 #                    (c) 1998 A.M. Thurnherr
     7 #                    uE-Info: 157 44 NIL 0 0 70 2 2 4 NIL ofnI
     7 #                    uE-Info: 652 28 NIL 0 0 70 2 2 4 NIL ofnI
     8 #======================================================================
     8 #======================================================================
     9 
     9 
    10 # HISTORY:
    10 # HISTORY:
    11 #	Dec 30, 1998: - removed directory from $0
    11 #	Dec 30, 1998: - removed directory from $0
    12 #				  - added global -P option (pass comments)
    12 #				  - added global -P option (pass comments)
   153 #	Oct 29, 2012: - diabled "no file" messages on special args
   153 #	Oct 29, 2012: - diabled "no file" messages on special args
   154 #	Mar 29, 2013: - added support for $ANTSLIBS
   154 #	Mar 29, 2013: - added support for $ANTSLIBS
   155 #	Apr  2, 2013: - BUG: pref{}suff special args did sometimes produce unexpanded as well
   155 #	Apr  2, 2013: - BUG: pref{}suff special args did sometimes produce unexpanded as well
   156 #						 as expanded output (unexpanded should be produced only if the
   156 #						 as expanded output (unexpanded should be produced only if the
   157 #						 expansion is empty)
   157 #						 expansion is empty)
       
   158 #	Jan 30, 2015: - added &antsFunOpt()
       
   159 #	Jan 31, 2015: - made it work
   158 
   160 
   159 # NOTES:
   161 # NOTES:
   160 #	- ksh expands {}-arguments with commas in them!!! Use + instead
   162 #	- ksh expands {}-arguments with commas in them!!! Use + instead
   161 
   163 
   162 use Getopt::Std;
   164 use Getopt::Std;
   630 	    	return $default;
   632 	    	return $default;
   631 	    }
   633 	    }
   632 	}
   634 	}
   633 }
   635 }
   634 
   636 
       
   637 #----------------------------------------------------------------------
       
   638 # antsFunOpt(\$opt_x) parses the contents of $opt_x as follows:
       
   639 #
       
   640 #	name(value)	=> $opt_x = 'name'; $name = "value";
       
   641 #	name		=> no change
       
   642 #----------------------------------------------------------------------
       
   643 
       
   644 sub antsFunOpt(@)
       
   645 {
       
   646 	my($opt) = @_;
       
   647 	return unless defined($opt);
       
   648 	croak("antsusage.pl: antsFunOpt(@_): argument is not a ref\n")
       
   649 		unless ref($opt);
       
   650 	my($name,$param) = (${$opt} =~ m{^([^\)]+)\(([^\)]+)\)$});
       
   651 	return unless defined($param);
       
   652 	eval(sprintf('$%s = "%s";',$name,$param));
       
   653 	${$opt} = $name;
       
   654 }
       
   655 
   635 1;														# return true
   656 1;														# return true