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 / local < prev    next >
Encoding:
Text File  |  1992-10-18  |  569 b   |  31 lines

  1. &RANGEVAL(20, 30, '$foo[$i] = $i');
  2.  
  3. sub RANGEVAL {
  4.     local($min, $max, $thunk) = @_;
  5.     local($result) = '';
  6.     local($i);
  7.  
  8.     # Presumably $thunk makes reference to $i
  9.  
  10.     for ($i = $min; $i < $max; $i++) {
  11.         $result .= eval $thunk;
  12.     }
  13.  
  14.     $result;
  15. }
  16.  
  17. if ($sw eq '-v') {
  18.     # init local array with global array
  19.     local(@ARGV) = @ARGV;
  20.     unshift(@ARGV, 'echo');
  21.     system @ARGV;
  22. }
  23. # @ARGV restored
  24.  
  25. # temporarily add a couple entries to %digits associative array
  26. if ($base12) {
  27.     # (NOTE: not claiming this is efficient!)
  28.     local(%digits) = (%digits, 't', 10, 'e', 11);
  29.     &parse_num();
  30. }
  31.