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 / ch5 / retnull.eg < prev    next >
Encoding:
Text File  |  1992-10-18  |  338 b   |  17 lines

  1. sub files {
  2.     local(*DH);
  3.     opendir(DH, $_[0]) || return 0;
  4.     local(@f) = sort grep(!/^\.\.?$/, readdir(DH));
  5.     closedir(DH);
  6.     return 1, @f;
  7. }
  8.  
  9. {
  10.     local(@return) = &files($ENV{HOME} || $ENV{LOGDIR});
  11.     if (shift @return) {
  12.     print "home files are @return\n";
  13.     } else {
  14.     print "cannot read home directory: $!\n";
  15.     }
  16. }
  17.