home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / !Perl / scripts / rm < prev    next >
Text File  |  1998-07-14  |  587b  |  40 lines

  1. #! perl
  2.  
  3. use RISCOS::Filespec;
  4. use RISCOS::File qw(globlist);
  5. use Getopt::Std;
  6.  
  7. getopts('r');
  8.  
  9. die "$0 [-r] [files]" unless @ARGV;
  10.  
  11. &rm (globlist( @ARGV ));
  12.  
  13. $fails = 0;
  14.  
  15. sub rm
  16. {
  17.     foreach( @_ )
  18.     {
  19.         if( $opt_r && -d $_ )
  20.         {
  21.             rm( glob "$_.*" );
  22.             unless( rmdir $_ )
  23.             {
  24.                 warn "$_ $!\n";
  25.                 $fails++;
  26.             }
  27.         }
  28.         else
  29.         {
  30.             unless( unlink $_ )
  31.             {
  32.                 warn "$_ $!\n";
  33.                 $fails++;
  34.             }
  35.             
  36.         }
  37.     }
  38. }
  39.  
  40. $fails != 0;