File:  [Local Repository] / db / prgsrc / chgkfiles.pm
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Mon Nov 19 01:16:17 2001 UTC (22 years, 6 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
-

    1: #!/usr/bin/perl
    2: 
    3: =head1 NAME
    4: 
    5: chgkfiles.pm - модуль для работы с файлами
    6: 
    7: =head1 SYNOPSIS
    8: 
    9:   use chgkfiles.pm  
   10: 
   11: =head1 DESCRIPTION
   12: 
   13:   Работа с файлами
   14: 
   15: =head1 AUTHOR
   16: 
   17: Роман Семизаров
   18: 
   19: =cut
   20: 
   21: package chgkfiles;
   22: use DBI;
   23: use Exporter;
   24: use vars qw(@ISA @EXPORT);
   25: @ISA=qw(Exporter);
   26: 
   27: @EXPORT = qw(&input_files &output_files &mywrite &auto_message 
   28:             &myprint &config_error &getstring);
   29: 
   30: 
   31: BEGIN {do "chgk.cnf"};
   32: 
   33: my %prt;
   34: 
   35: sub auto_message
   36: {
   37:   my $time=localtime;
   38:   my $f=$_[0];
   39: 
   40:   print $f "# This file is automatically generated at $time by $_[1]\n";
   41: }
   42: 
   43: sub mywrite
   44: {
   45:   (my $file, %prt)=@_;
   46:   write $file;
   47: }
   48: 
   49: sub myprint
   50: {
   51:   (my $file, @prt)=@_;
   52:   print $file @prt;
   53: }
   54: 
   55: sub setcount
   56: {
   57:   $c=shift
   58: }
   59: 
   60: sub setword
   61: {
   62:   $word=shift
   63: }
   64: 
   65: 
   66: sub getstring #АЕП╦Р ОЕПБСЧ
   67: {
   68: 
   69:    if ($#_>=1) { $a=$_[1]; $pattern=qr/$_[0]/}
   70:    else {$a=$_[0]; $pattern=qr/\s+/};
   71:    do
   72:    {   
   73:      $b=<$a>;
   74:      $b =~ s/^\s+//g;
   75:      $b =~ s/\s+$//g;
   76:      $b =~ s/\#.*$//g;
   77:    }
   78:    until (($b ne '')||eof($a));
   79: 
   80: 
   81:   $b ? split(/$pattern/, $b):undef;
   82: }
   83: 
   84: sub config_error()
   85: {
   86:   "Can not open $_[0] file ${$_[0]}. Check your config.pl";
   87: }
   88: 
   89: 
   90: 
   91: sub input_files
   92: {
   93:     foreach $file (@_) 
   94:     {
   95:           my $f=lc $file;
   96:           open($file, "<$$f") or die "Can not open $file file $$f. Check your chgk.cnf\n";
   97:     }
   98: }
   99: 
  100: sub output_files
  101: {
  102:     foreach $file (@_) 
  103:     {
  104:           my $f=lc $file;
  105:           open($file, ">$$f") or die "Can not open $file file $$f. Check your chgk.cnf\n";
  106:     }
  107: }
  108: 
  109: format WORDLIST =
  110: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  111: $prt{c}, $prt{word}
  112: .
  113: 
  114: 	
  115: format DWORDLIST =
  116: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  117: $prt{c}, $prt{word}
  118: .
  119: 
  120: format VWORDLIST =
  121: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  122: $prt{c}, $prt{word}
  123: .
  124: 
  125: 
  126: format EWORDLIST =
  127: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  128: $prt{c}, $prt{word}
  129: .
  130: 
  131: format KWORDLIST =
  132: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  133: $prt{c}, $prt{word}
  134: .
  135: 
  136: 
  137: 
  138: format TABLE =
  139: @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  140: $prt{word}, $prt{nf}, $prt{flag}
  141: .
  142: 
  143: format NEWTABLE =
  144: @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  145: $prt{word}, $prt{nf}
  146: .
  147: 
  148: 
  149: 
  150: format NF =
  151: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  152: $prt{c}, $prt{word}, $prt{flag}
  153: .
  154: 
  155: format NEWNF =
  156: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  157: $prt{c}, $prt{word}
  158: .
  159: 
  160: 
  161: format ERRORS =
  162: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  163: $prt{c}, $prt{word}
  164: .
  165: 
  166: format NEWERRORS =
  167: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  168: $prt{c}, $prt{word}
  169: .
  170: 
  171: format VERSIONS =
  172: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  173: $prt{c}, $prt{word}, $prt{k}
  174: .
  175: 
  176: format EQUALS =
  177: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  178: $prt{first}, $prt{second}
  179: .
  180: 
  181: format IN2OUT =
  182: @<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  183: $prt{in}, $prt{out}
  184: .
  185: 
  186: format CTABLE =
  187: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  188: $prt{word}, $prt{number}
  189: .
  190: 
  191: format CNF =
  192: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  193: $prt{kvo}
  194: .
  195: 
  196: format ALIKE  =
  197: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  198: $prt{first}, $prt{second}
  199: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
  200: $prt{first}, $prt{second}
  201: .
  202: 
  203: 
  204: 1;
  205: 
  206: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>