#!/usr/bin/perl =head1 NAME chgkfiles.pm - модуль для работы с файлами =head1 SYNOPSIS use chgkfiles.pm =head1 DESCRIPTION Работа с файлами =head1 AUTHOR Роман Семизаров =cut package chgkfiles; use DBI; use Exporter; use vars qw(@ISA @EXPORT); @ISA=qw(Exporter); @EXPORT = qw(&input_files &output_files &mywrite &auto_message &myprint &config_error &getstring); BEGIN {do "chgk.cnf"}; my %prt; sub auto_message { my $time=localtime; my $f=$_[0]; print $f "# This file is automatically generated at $time by $_[1]\n"; } sub mywrite { (my $file, %prt)=@_; write $file; } sub myprint { (my $file, @prt)=@_; print $file @prt; } sub setcount { $c=shift } sub setword { $word=shift } sub getstring #АЕП╦Р ОЕПБСЧ { if ($#_>=1) { $a=$_[1]; $pattern=qr/$_[0]/} else {$a=$_[0]; $pattern=qr/\s+/}; do { $b=<$a>; $b =~ s/^\s+//g; $b =~ s/\s+$//g; $b =~ s/\#.*$//g; } until (($b ne '')||eof($a)); $b ? split(/$pattern/, $b):undef; } sub config_error() { "Can not open $_[0] file ${$_[0]}. Check your config.pl"; } sub input_files { foreach $file (@_) { my $f=lc $file; open($file, "<$$f") or die "Can not open $file file $$f. Check your chgk.cnf\n"; } } sub output_files { foreach $file (@_) { my $f=lc $file; open($file, ">$$f") or die "Can not open $file file $$f. Check your chgk.cnf\n"; } } format WORDLIST = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format DWORDLIST = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format VWORDLIST = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format EWORDLIST = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format KWORDLIST = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format TABLE = @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{word}, $prt{nf}, $prt{flag} . format NEWTABLE = @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{word}, $prt{nf} . format NF = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word}, $prt{flag} . format NEWNF = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format ERRORS = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format NEWERRORS = @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word} . format VERSIONS = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{c}, $prt{word}, $prt{k} . format EQUALS = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{first}, $prt{second} . format IN2OUT = @<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{in}, $prt{out} . format CTABLE = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{word}, $prt{number} . format CNF = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{kvo} . format ALIKE = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $prt{first}, $prt{second} ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $prt{first}, $prt{second} . 1; __END__