home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / perl / 7926 < prev    next >
Encoding:
Text File  |  1993-01-21  |  20.0 KB  |  623 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!panther!mothost!schbbs!cssmp.corp.mot.com!mmuegel
  3. From: mmuegel@cssmp.corp.mot.com (Michael S. Muegel)
  4. Subject: Tool to determine required libraries
  5. Organization: Corporate Information Office, Schaumburg, Illinois, Motorola, Inc.
  6. Date: Thu, 21 Jan 1993 01:08:55 GMT
  7. Message-ID: <1993Jan21.010855.19199@schbbs.mot.com>
  8. Sender: news@schbbs.mot.com (Net News)
  9. Nntp-Posting-Host: cssmp.corp.mot.com
  10. Lines: 611
  11.  
  12.  
  13. I got tired today of always figuring out what libs a program needed when
  14. I wanted to pack something up for someone. So a wrote a little tool to
  15. determine what libraries a program needed. Before you say "hey, that
  16. is impossible" read the manual page. The tool could miss stuff because of
  17. the interpreted nature of Perl; however, it works for all the programs I
  18. threw at it. And it is graceful if it does screw up.
  19.  
  20. Feedback is encouraged. I hope there was not some easy way to do this
  21. via Perl other than working with %INC within your program. This method
  22. would require you to edit your program. 
  23.  
  24. Regards,
  25. -Mike
  26.  
  27. ---- Cut Here and feed the following to sh ----
  28. #!/bin/sh
  29. # This is a shell archive (produced by shar 3.49)
  30. # To extract the files from this archive, save it to a file, remove
  31. # everything above the "!/bin/sh" line above, and type "sh file_name".
  32. #
  33. # made 01/21/1993 01:07 UTC by mmuegel@mot.com (Michael S. Muegel)
  34. # Source directory /home/ustart/NeXT/src/perl-stuff/tools
  35. #
  36. # existing files will NOT be overwritten unless -c is specified
  37. #
  38. # This shar contains:
  39. # length  mode       name
  40. # ------ ---------- ------------------------------------------
  41. #   3511 -r--r--r-- prequire.man
  42. #   2257 -r-xr-xr-x prequire
  43. #   3497 -r--r--r-- fileinfo.pl
  44. #   7030 -r--r--r-- newgetopts.pl
  45. #
  46. # ============= prequire.man ==============
  47. if test -f 'prequire.man' -a X"$1" != X"-c"; then
  48.     echo 'x - skipping prequire.man (File already exists)'
  49. else
  50. echo 'x - extracting prequire.man (Text)'
  51. sed 's/^X//' << 'SHAR_EOF' > 'prequire.man' &&
  52. .TH PREQUIRE 1L
  53. \"
  54. \" $Author: mmuegel $
  55. \" $Header: /usr/local/ustart/src/perl-stuff/tools/man/prequire.man,v 1.1 1993/01/21 01:06:36 mmuegel Exp $
  56. \"
  57. .ds mp \fBprequire\fR
  58. .SH NAME
  59. \*(mp - get a list of the required Perl libraries
  60. .SH SYNOPSIS
  61. \*(mp [ \fB-s\fR ] [ \fIfile ...\fR ]
  62. .SH DESCRIPTION
  63. \*(mp will try to determine, recursively as necessary, what Perl libraries
  64. are used by the Perl file(s) specified.  Because of Perl's interpreted nature it
  65. is difficult to determine what files are included; there are so many ways
  66. to do it and many could only be determined at run time. Therefore,
  67. \*(mp looks for the following statements to appear at the beginning of
  68. a line (leading white space allowed):
  69. .sp 1
  70. .RS
  71. .nf
  72. require "file"
  73. require 'file'
  74. do "file"
  75. do 'file'
  76. do file
  77. .fi
  78. .RE
  79. .sp 1
  80. The pathnames that get printed are absolute and show the actual location
  81. of the library in a filesystem. That is, link pathnames are not shown. 
  82. Similar to Perl (except more exacting) \*(mp will not parse any
  83. required file more than once.
  84. .sp 1
  85. When an error occurs \*(mp prints a descriptive message and continues.
  86. An error might occur when a Perl library is not in @INC or the parser was
  87. confused. A hereis file that contains leading text matching the 
  88. require and do syntax described above can easily cause problems (try
  89. \fBperldb.pl\fR).
  90. .SH OPTIONS
  91. .IP \fB-s\fR
  92. Print the pathnames on the same line separated by a space. The default is
  93. to print one pathname per line.
  94. .IP \fIfile\fR
  95. One or more files to parse. If none are specified standard input is used.
  96. .SH EXAMPLES
  97. In the following example the library pathname compiled into Perl is 
  98. \fB/usr/local/ustart/contrib/lib/perl\fR. This is linked to the \fB/home\fR 
  99. area. \fBPERLLIB\fR is not set.
  100. .sp 1
  101. .nf
  102. % \fBpwd\fR
  103. /home/ustart/NeXT/src/perl-stuff/tools/test
  104. X
  105. % \fBls\fR
  106. config.pl  input.pl
  107. X
  108. % \fBcat input.pl\fR
  109. # Some test requires
  110. require "newgetopts.pl";
  111. require '../test/config.pl';
  112. X
  113. # Some test dos
  114. do 'ftp.pl';
  115. do dbedit.pl;
  116. X
  117. # Stuff I should ignore
  118. do sub ();
  119. do $sub ();
  120. X
  121. % \fBprequire input.pl\fR
  122. /home/ustart/NeXT/contrib/lib/perl/chat2.pl
  123. /home/ustart/NeXT/contrib/lib/perl/date.pl
  124. /home/ustart/NeXT/contrib/lib/perl/dbedit.pl
  125. /home/ustart/NeXT/contrib/lib/perl/dbfuncs.pl
  126. /home/ustart/NeXT/contrib/lib/perl/dbread.pl
  127. /home/ustart/NeXT/contrib/lib/perl/dbwrite.pl
  128. /home/ustart/NeXT/contrib/lib/perl/ftp.pl
  129. /home/ustart/NeXT/contrib/lib/perl/newgetopts.pl
  130. /home/ustart/NeXT/src/perl-stuff/tools/test/config2.pl
  131. /home/ustart/Sun-4.0/contrib/lib/perl.platform/sys/socket.ph
  132. .fi
  133. .sp 1
  134. In this example \*(mp is used to create a shar file for itself.
  135. .sp 1
  136. .nf
  137. % \fBshar -f man/prequire.man src/prequire `prequire src/prequire` > prequire.shar\fR
  138. shar: saving man/prequire.man (Text)
  139. shar: saving src/prequire (Text)
  140. shar: saving /home/ustart/NeXT/contrib/lib/perl/fileinfo.pl (Text)
  141. shar: saving /home/ustart/NeXT/contrib/lib/perl/newgetopts.pl (Text)
  142. .fi
  143. .SH ENVIRONMENT VARIABLES
  144. .IP \fBPERLLIB\fR 10
  145. This modifies @INC. See \fBperl(1l)\fR.
  146. .SH AUTHOR
  147. .nf
  148. Michael S. Muegel (mmuegel@mot.com)
  149. UNIX Applications Startup Group
  150. Corporate Information Office, Schaumburg, IL
  151. Motorola, Inc.
  152. .fi
  153. .SH COPYRIGHT NOTICE
  154. Copyright 1993, Motorola, Inc.
  155. .sp 1
  156. Permission to use, copy, modify and distribute without charge this
  157. software, documentation, etc. is granted, provided that this
  158. comment and the author's name is retained.  The author nor Motorola assume any
  159. responsibility for problems resulting from the use of this software.
  160. .SH SEE ALSO
  161. \fBperl(1l)\fR
  162. SHAR_EOF
  163. chmod 0444 prequire.man ||
  164. echo 'restore of prequire.man failed'
  165. Wc_c="`wc -c < 'prequire.man'`"
  166. test 3511 -eq "$Wc_c" ||
  167.     echo 'prequire.man: original size 3511, current size' "$Wc_c"
  168. fi
  169. # ============= prequire ==============
  170. if test -f 'prequire' -a X"$1" != X"-c"; then
  171.     echo 'x - skipping prequire (File already exists)'
  172. else
  173. echo 'x - extracting prequire (Text)'
  174. sed 's/^X//' << 'SHAR_EOF' > 'prequire' &&
  175. #!/usr/local/ustart/bin/perl
  176. X
  177. # NAME
  178. #    prequire - get a list of the required Perl libraries
  179. #
  180. # SYNOPSIS
  181. #    prequire [ -s ] [ file ... ]
  182. #
  183. # AUTHOR
  184. #    Michael S. Muegel <mmuegel@mot.com>
  185. #
  186. # RCS INFORMATION
  187. #    $Author: mmuegel $
  188. #    $Source: /usr/local/ustart/src/perl-stuff/tools/src/prequire,v $
  189. #    $Revision: 1.1 $ of $Date: 1993/01/21 00:31:08 $
  190. X
  191. # A better getopts routine
  192. require "newgetopts.pl";
  193. require "fileinfo.pl";
  194. X
  195. # Get the basename of the script
  196. ($Script_Name = $0) =~ s/.*\///;
  197. X         
  198. # Some famous constants
  199. $USAGE          = "Usage: $Script_Name [ -s ] [ file ... ]\n";
  200. $VERSION        = "${Script_Name} by \$Author: mmuegel $; \$Revision: 1.1 $ of \$Date: 1993/01/21 00:31:08 $";
  201. $SWITCHES       = "s";
  202. X
  203. # Let getopts parse for switches
  204. $Status = &New_Getopts($SWITCHES, $USAGE);
  205. exit (0) if ($Status == -1);
  206. exit (1) if (! $Status);
  207. X
  208. # To figure out what has been required for each program we make an attempt
  209. # to parse for requires.
  210. INPUT: while (<>)
  211. {
  212. X   # Look for various do/require syntaxs described in the manual page
  213. X   next if (! (/^\s*(do|require)\s+['"]([^'"]+)['"]/ || /^\s*(do)\s+([^{\s\$;\(\)]+)/));
  214. X   ($Op, $Lib, $Left) = ($1, $2, $');
  215. X   next if (($Op eq "do") && ($Left =~ /^\s+\(/));
  216. X
  217. X   # Figure out which directory in @INC $Lib came from if the pathname
  218. X   # was relative
  219. X   if ($Lib !~ /^[\/\.]/)
  220. X   {
  221. X      $Found = 0;
  222. X      foreach $Dir (@INC)
  223. X      {
  224. X         if (-f "$Dir/$Lib")
  225. X         {
  226. X            $Found = 1;
  227. X            $Lib = "$Dir/$Lib";
  228. X            last;
  229. X         };
  230. X      };
  231. X
  232. X      # If we did not find it something is afoot
  233. X      if (! $Found)
  234. X      {
  235. X         warn "$Script_Name: $ARGV line $.: \"$Lib\" not found it in \@INC\n";
  236. X     next INPUT;
  237. X      };
  238. X   };
  239. X
  240. X   # OK, now figure out the real pathname of this lib
  241. X   ($Status, $Lib) = &Real_Path ($Lib);
  242. X   if (! $Status)
  243. X   {
  244. X      warn "$Script_Name: $ARGV line $.: $Lib\n" if (! $Status);
  245. X      next INPUT;
  246. X   };
  247. X
  248. X   # Save the library for later use and push it on the input stack so we
  249. X   # look inside of it as well
  250. X   push (@ARGV, $Lib) if (! $Lib_Status {$Lib}++);
  251. };
  252. X
  253. # Now print 'em out
  254. @Libs = sort (keys (%Lib_Status));
  255. if (@Libs)
  256. {
  257. X   $Sep = ($opt_s) ? " " : "\n";
  258. X   print join ($Sep, sort (keys (%Lib_Status))) . "\n";
  259. };
  260. SHAR_EOF
  261. chmod 0555 prequire ||
  262. echo 'restore of prequire failed'
  263. Wc_c="`wc -c < 'prequire'`"
  264. test 2257 -eq "$Wc_c" ||
  265.     echo 'prequire: original size 2257, current size' "$Wc_c"
  266. fi
  267. # ============= fileinfo.pl ==============
  268. if test -f 'fileinfo.pl' -a X"$1" != X"-c"; then
  269.     echo 'x - skipping fileinfo.pl (File already exists)'
  270. else
  271. echo 'x - extracting fileinfo.pl (Text)'
  272. sed 's/^X//' << 'SHAR_EOF' > 'fileinfo.pl' &&
  273. ;# NAME
  274. ;#    fileinfo.pl - perl function(s) give information on file system objects
  275. ;#
  276. ;# AUTHOR
  277. ;#    Michael S. Muegel (mmuegel@mot.com)
  278. ;#
  279. ;# RCS INFORMATION
  280. ;#    $Author: mmuegel $
  281. ;#    $Header: /usr/local/ustart/src/perl-stuff/libs/fwrdc/misc/RCS/fileinfo.pl,v 1.2 1993/01/20 23:36:51 mmuegel Exp $
  282. ;#    $Source: /usr/local/ustart/src/perl-stuff/libs/fwrdc/misc/RCS/fileinfo.pl,v $
  283. X
  284. package fileinfo;
  285. X
  286. # Maximum number of times I can encounter a pathname when figuring out
  287. # real pathname
  288. $MAX_VISITS     = 8;
  289. X
  290. # The print working directory command
  291. $PWD         = "/bin/pwd";
  292. X
  293. ;###############################################################################
  294. ;# Dir_Name
  295. ;#
  296. ;# Returns the name of the directory that $Path is in. The name is the
  297. ;# logical name. E.g. no link following is done.
  298. ;#
  299. ;# Written by me@anywhere.EBay.Sun.COM (Wayne Thompson) and posted to c.l.p.
  300. ;# Modified to work with Domain/OS // filesystem.
  301. ;#
  302. ;# Arguments:
  303. ;#    $Path
  304. ;#
  305. ;# Returns:
  306. ;#    $Dir
  307. ;###############################################################################
  308. sub main'Dir_Name 
  309. {   
  310. X    local ($_) = @_;
  311. X    local ($return);
  312. X    s#$#/#;
  313. X    (($return) = m#^(/[/]?)[^/]*/$#) ||
  314. X        (($return) = m#(.*[^/])/+[^/]+/+$#) ||
  315. X        ($return = '.');
  316. X    $return;
  317. };
  318. X
  319. X
  320. ;###############################################################################
  321. ;# Real_Path
  322. ;#
  323. ;# Determines the actual physical path of $Path. It will follow links if
  324. ;# necessary. When sitting in my $HOME and given "bin" will return
  325. ;# //fwase12/users/mmuegel/bin. Returns with $Status 1 if it was able to
  326. ;# compute the real path; 0 otherwise. If 0 an error string is returned
  327. ;# instead of the pathname. Catches recursive links by setting a limit on the 
  328. ;# number of times a pathname can be encountered. The maximum number is 
  329. ;# $MAX_VISITS.
  330. ;#
  331. ;# Arguments:
  332. ;#    $Path
  333. ;#
  334. ;# Returns:
  335. ;#    $Status, $Real_Path
  336. ;###############################################################################
  337. sub main'Real_Path
  338. {
  339. X   local ($Logical_Path) = @_;
  340. X   local (%Traversed_Count, $Start_Dir, $Status, $Real_Path);
  341. X
  342. X   sub Real_Path_Rec
  343. X   {
  344. X      local ($Path) = @_;
  345. X      local ($Basename, $Dir, $New_Path, $Real_Path, $Error);
  346. X
  347. X      # Check for recursion
  348. X      return (0, "$Logical_Path: possible recursion for object $Path") 
  349. X         if ($Traversed_Count {$Path}++ == $MAX_VISITS);
  350. X
  351. X      # Get the basename and directory $Path is in
  352. X      ($Basename = $Path) =~ s/.*\///;
  353. X      $Dir = &main'Dir_Name ($Path);
  354. X      
  355. X      # Collapse //node/.. -> // because of bug in Domain/OS
  356. X      $Dir =~ s#^//[^/]+/\.\.#//#;
  357. X
  358. X      # Change to the directory $Path is in
  359. X      chdir ($Dir) || return (0, "$Logical_Path: could not chdir to $Dir: $!") if ($Dir ne ".");
  360. X      chop ($Dir = `$PWD 2>/dev/null`) || return (0, "$Logical_Path: can not get current working directory");
  361. X   
  362. X      if (-l $Basename)
  363. X      {
  364. X         $New_Path = readlink ($Basename) || return (0, "$Logical_Path: can not read link $Path/$Basename");
  365. X         return (&Real_Path_Rec ($New_Path));
  366. X      };
  367. X   
  368. X      chop ($Dir) if ($Dir =~ /^(\/){1,2}$/);
  369. X      return (1, "$Dir/$Basename");
  370. X   };
  371. X
  372. X   # Save the cwd, figure out real path, and change back to cwd
  373. X   chop ($Start_Dir = `$PWD 2>/dev/null`) || return (0, "$Logical_Path: can not get current working directory");
  374. X   ($Status, $Real_Path) = &Real_Path_Rec ($Logical_Path);
  375. X   chdir ($Start_Dir) || return (0, "$Logical_Path: could not chdir to $Start_Dir: $!");
  376. X   return ($Status, $Real_Path);
  377. X
  378. };
  379. X
  380. 1;
  381. SHAR_EOF
  382. chmod 0444 fileinfo.pl ||
  383. echo 'restore of fileinfo.pl failed'
  384. Wc_c="`wc -c < 'fileinfo.pl'`"
  385. test 3497 -eq "$Wc_c" ||
  386.     echo 'fileinfo.pl: original size 3497, current size' "$Wc_c"
  387. fi
  388. # ============= newgetopts.pl ==============
  389. if test -f 'newgetopts.pl' -a X"$1" != X"-c"; then
  390.     echo 'x - skipping newgetopts.pl (File already exists)'
  391. else
  392. echo 'x - extracting newgetopts.pl (Text)'
  393. sed 's/^X//' << 'SHAR_EOF' > 'newgetopts.pl' &&
  394. ;# NAME
  395. ;#    newgetopts.pl - a better newgetopt (which is a better getopts which is
  396. ;#                    a better getopt ;-)
  397. ;#
  398. ;# AUTHOR
  399. ;#    Mike Muegel (mmuegel@mot.com)
  400. ;#
  401. ;# $Author: mmuegel $
  402. ;# $Header: //fwans00/usr/local/lib/perl/RCS/newgetopts.pl,v 1.6 91/09/05 16:29:39 mmuegel Exp $
  403. X
  404. ;###############################################################################
  405. ;# New_Getopts
  406. ;#
  407. ;# Does not care about order of switches, options, and arguments like 
  408. ;# getopts.pl. Thus all non-switches/options will be kept in ARGV even if they
  409. ;# are not at the end. If $Pass_Invalid is set all unkown options will be
  410. ;# passed back to the caller by keeping them in @ARGV. This is useful when
  411. ;# parsing a command line for your script while ignoring options that you
  412. ;# may pass to another script. If this is set New_Getopts tries to maintain 
  413. ;# the switch clustering on the unkown switches.
  414. ;#
  415. ;# Accepts the special argument -usage to print the Usage string. Also accepts 
  416. ;# the special option -version which prints the contents of the string 
  417. ;# $VERSION. $VERSION may or may not have an embeded \n in it. If -usage 
  418. ;# or -version are specified a status of -1 is returned. Note that the usage
  419. ;# option is only accepted if the usage string is not null.
  420. ;# 
  421. ;# $Switches is just like the formal arguemnt of getopts.pl. $Usage is a usage
  422. ;# string with or without a trailing \n. *Switch_To_Order is an optional
  423. ;# pointer to the name of an associative array which will contain a mapping of
  424. ;# switch names to the order in which (if at all) the argument was entered.
  425. ;#
  426. ;# For example, if @ARGV contains -v, -x, test:
  427. ;#
  428. ;#    $Switch_To_Order {"v"} = 1;
  429. ;#    $Switch_To_Order {"x"} = 2;
  430. ;#
  431. ;# Note that in the case of multiple occurances of an option $Switch_To_Order
  432. ;# will store each occurance of the argument via a string that emulates
  433. ;# an array. This is done by using join ($;, ...). You can retrieve the
  434. ;# array by using split (/$;/, ...).
  435. ;#
  436. ;# *Split_ARGV is an optional pointer to an array which will conatin the
  437. ;# original switches along with their values. For the example used above 
  438. ;# Split_ARGV would contain:
  439. ;#
  440. ;#   @Split_ARGV = ("v", "", "x", "test");
  441. ;#
  442. ;# Another exciting ;-) feature that newgetopts has. Along with creating the 
  443. ;# normal $opt_ scalars for the last value of an argument the list @opt_ is 
  444. ;# created. It is an array which contains all the values of arguments to the 
  445. ;# basename of the variable. They are stored in the order which they occured 
  446. ;# on the command line starting with $[. Note that blank arguments are stored 
  447. ;# as "". Along with providing support for multiple options on the command 
  448. ;# line this also provides a method of counting the number of times an option 
  449. ;# was specified via $#opt_.
  450. ;#
  451. ;# Automatically resets all $opt_, @opt_, %Switch_To_Order, and @Split_ARGV
  452. ;# variables so that New_Getopts may be called more than once from within
  453. ;# the same program. Thus, if $opt_v is set upon entry to New_Getopts and 
  454. ;# -v is not in @ARGV $opt_v will not be set upon exit.
  455. ;#
  456. ;# Arguments:
  457. ;#    $Switches, $Usage, $Pass_Invalid, *Switch_To_Order, *Split_ARGV
  458. ;#
  459. ;# Returns:
  460. ;#    -1, 0, or 1 depending on status (printed Usage/Version, OK, not OK)
  461. ;###############################################################################
  462. sub New_Getopts 
  463. {
  464. X    local($taint_argumentative, $Usage, $Pass_Invalid, *Switch_To_Order,
  465. X          *Split_ARGV) = @_;
  466. X    local(@args,$_,$first,$rest,$errs, @leftovers, @current_leftovers,
  467. X          %Switch_Found);
  468. X    local($[, $*, $Script_Name, $argumentative);
  469. X
  470. X    # Untaint the argument cluster so that we can use this with taintperl
  471. X    $taint_argumentative =~ /^(.*)$/;
  472. X    $argumentative = $1;
  473. X
  474. X    # Clear anything that might still be set from a previous New_Getopts
  475. X    # call.
  476. X    @Split_ARGV = ();
  477. X
  478. X    # Get the basename of the calling script
  479. X    ($Script_Name = $0) =~ s/.*\///;
  480. X    
  481. X    # Make Usage have a trailing \n
  482. X    $Usage .= "\n" if ($Usage !~ /\n$/);
  483. X
  484. X    @args = split( / */, $argumentative );
  485. X
  486. X    # Clear anything that might still be set from a previous New_Getopts call.
  487. X    foreach $first (@args)
  488. X    {
  489. X       next if ($first eq ":");
  490. X       delete $Switch_Found {$first};
  491. X       delete $Switch_To_Order {$first};
  492. X       eval "undef \@opt_$first; undef \$opt_$first;";
  493. X    };
  494. X
  495. X    while (@ARGV)
  496. X    {
  497. X        # Let usage through
  498. X        if (($ARGV[0] eq "-usage") && ($Usage ne "\n"))
  499. X        {
  500. X           print $Usage;
  501. X           exit (-1);
  502. X        }
  503. X
  504. X        elsif ($ARGV[0] eq "-version")
  505. X        {
  506. X           if ($VERSION)
  507. X           {
  508. X              print $VERSION;
  509. X              print "\n" if ($VERSION !~ /\n$/);
  510. X           }
  511. X           else
  512. X           {
  513. X              warn "${Script_Name}: no version information available, sorry\n";
  514. X           }
  515. X           exit (-1);
  516. X        }
  517. X
  518. X        elsif (($_ = $ARGV[0]) =~ /^-(.)(.*)/)
  519. X        {
  520. X           ($first,$rest) = ($1,$2);
  521. X           $pos = index($argumentative,$first);
  522. X
  523. X           $Switch_To_Order {$first} = join ($;, split (/$;/, $Switch_To_Order {$first}), ++$Order);
  524. X
  525. X           if($pos >= $[) 
  526. X           {
  527. X               if($args[$pos+1] eq ':') 
  528. X               {
  529. X                   shift(@ARGV);
  530. X                   if($rest eq '') 
  531. X                   {
  532. X                       $rest = shift(@ARGV);
  533. X                   }
  534. X
  535. X                   eval "\$opt_$first = \$rest;";
  536. X                   eval "push (\@opt_$first, \$rest);";
  537. X                   push (@Split_ARGV, $first, $rest);
  538. X               }
  539. X               else 
  540. X               {
  541. X                   eval "\$opt_$first = 1";
  542. X                   eval "push (\@opt_$first, '');";
  543. X                   push (@Split_ARGV, $first, "");
  544. X
  545. X                   if($rest eq '') 
  546. X                   {
  547. X                       shift(@ARGV);
  548. X                   }
  549. X                   else 
  550. X                   {
  551. X                       $ARGV[0] = "-$rest";
  552. X                   }
  553. X               }
  554. X           }
  555. X
  556. X           else 
  557. X           {
  558. X               # Save any other switches if $Pass_Valid
  559. X               if ($Pass_Invalid)
  560. X               {
  561. X                  push (@current_leftovers, $first);
  562. X               }
  563. X               else
  564. X               {
  565. X                  warn "${Script_Name}: unknown option: $first\n";
  566. X                  ++$errs;
  567. X               };
  568. X               if($rest ne '') 
  569. X               {
  570. X                   $ARGV[0] = "-$rest";
  571. X               }
  572. X               else 
  573. X               {
  574. X                   shift(@ARGV);
  575. X               }
  576. X           }
  577. X        }
  578. X
  579. X        else
  580. X        {
  581. X           push (@leftovers, shift (@ARGV));
  582. X        };
  583. X
  584. X        # Save any other switches if $Pass_Valid
  585. X        if ((@current_leftovers) && ($rest eq ''))
  586. X        {
  587. X           push (@leftovers, "-" . join ("", @current_leftovers));
  588. X           @current_leftovers = ();
  589. X        };
  590. X    };
  591. X
  592. X    # Automatically print Usage if a warning was given
  593. X    @ARGV = @leftovers;
  594. X    if ($errs != 0)
  595. X    {
  596. X       warn $Usage;
  597. X       return (0);
  598. X    }
  599. X    else
  600. X    {
  601. X       return (1);
  602. X    }
  603. X       
  604. }
  605. X
  606. 1;
  607. SHAR_EOF
  608. chmod 0444 newgetopts.pl ||
  609. echo 'restore of newgetopts.pl failed'
  610. Wc_c="`wc -c < 'newgetopts.pl'`"
  611. test 7030 -eq "$Wc_c" ||
  612.     echo 'newgetopts.pl: original size 7030, current size' "$Wc_c"
  613. fi
  614. exit 0
  615.  
  616. -- 
  617. +----------------------------------------------------------------------------+
  618. | Michael S. Muegel                  | Internet E-Mail:    mmuegel@mot.com   |
  619. | UNIX Applications Startup Group    | Moto Dist E-Mail:   X10090            |
  620. | Corporate Information Office       | Voice:              (708) 576-0507    |
  621. | Motorola                           | ... these are my opinions, honest ... |
  622. +----------------------------------------------------------------------------+
  623.