home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / perl / nutshell / ch4 / includes < prev    next >
Encoding:
Text File  |  1992-10-18  |  459 b   |  22 lines

  1. # Process argument list of files along with any includes.
  2.  
  3. foreach $file (@ARGV) {
  4.     &process($file, 'fh00');
  5. }
  6.  
  7. sub process {
  8.     local($filename, $input) = @_;
  9.     $input++;               # this is a string increment
  10.     unless (open($input, $filename)) {
  11.         print STDERR "Can't open $filename: $!\n";
  12.         return;
  13.     }
  14.     while (<$input>) {      # note the use of indirection
  15.         if (/^#include "(.*)"/) {
  16.             &process($1, $input);
  17.             next;
  18.         }
  19.         ...           # whatever
  20.     }
  21. }
  22.