home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / bin / y2accel.pl < prev    next >
Encoding:
Perl Script  |  2000-03-30  |  1004 b   |  61 lines

  1. #!/usr/bin/perl
  2. # Copyright (c) 1996 S.u.S.E. GmbH Fuerth, Germany.  All rights reserved.
  3. #
  4. # Author: Marcus Schaefer <sax@suse.de>, 1999
  5. #
  6. # y2accel.pl YaST2 script to remove the noaccel statement
  7. # within the final config file
  8. #
  9.  
  10.  use Getopt::Long;
  11.  
  12. #----[ main ]-----#
  13. sub main {
  14.  undef($File); 
  15.  
  16.  # get options...
  17.  # ---------------
  18.  $result = GetOptions(
  19.    "file|f=s" => \$File,
  20.    "help|h"   => \&usage,
  21.    "<>"       => \&usage
  22.  );
  23.  if ( $result != 1 ) {
  24.   usage();
  25.  }
  26.  
  27.  # test file...
  28.  # -------------
  29.  if ($File eq "") {
  30.   print "no input file specified\n";
  31.   usage();
  32.  } elsif (! -f $File) {
  33.   print "file $File does not exist\n";
  34.   exit(1);
  35.  }
  36.  
  37.  open (FD,"$File");
  38.  while ($line=<FD>) {
  39.   if ($line !~ /noaccel/i) {
  40.    push(@list,$line);
  41.   }
  42.  }
  43.  close(FD);
  44.  open (FD,">$File");
  45.  print FD @list;  
  46.  close(FD);
  47.  exit(0);
  48. }
  49.  
  50. #---[ usage ]----#
  51. sub usage {
  52.  print "usage: y2accel [ options ]\n";
  53.  print "options:\n";
  54.  print "[ -f | --file ]\n";
  55.  print "  file to change\n";
  56.  exit(0);
  57. }
  58.  
  59.  
  60. main();
  61.