1.1 --- a/email-filter.pl Tue Jun 21 02:16:26 2011 +0400
1.2 +++ b/email-filter.pl Tue Jun 21 02:28:42 2011 +0400
1.3 @@ -7,42 +7,46 @@
1.4 my $isSplitByDomens = 0;
1.5 my $excludeDomen;
1.6
1.7 -# Парсим параметры командной строки
1.8 -my $arg = shift();
1.9 -my $isHasArgs = 0;
1.10 -until ($arg eq '') {
1.11 - $isHasArgs = 1;
1.12 - if($arg =~ /^-{1,2}.+$/){
1.13 - if ($arg =~ /^-{1,2}version$/){
1.14 - about();
1.15 - exit 0;
1.16 - } elsif ($arg =~ /^-{1,2}help$/){
1.17 - help();
1.18 - exit 0;
1.19 - } elsif ($arg eq '--remove-duplicates'){
1.20 - $isRemoveDuplicates = 1;
1.21 - } elsif ($arg eq '--split-by-domens'){
1.22 - $isSplitByDomens = 1;
1.23 - } elsif ($arg =~ /--exclude-domen[=]{0,1}(\w*)/){
1.24 - $excludeDomen = $1;
1.25 - illegalUse() if $excludeDomen ne '' && $arg !~ /--exclude-domen=\w*/;
1.26 - $excludeDomen = shift() if $excludeDomen eq '';
1.27 - illegalUse() if $excludeDomen eq '';
1.28 +parseCommandLine();
1.29 +processFile();
1.30 +exit 0;
1.31 +
1.32 +# Парсер параметров командной строки
1.33 +sub parseCommandLine {
1.34 + my $arg = shift(@ARGV);
1.35 + my $isHasArgs = 0;
1.36 + until ($arg eq '') {
1.37 + $isHasArgs = 1;
1.38 + if($arg =~ /^-{1,2}.+$/){
1.39 + if ($arg =~ /^-{1,2}version$/){
1.40 + about();
1.41 + exit 0;
1.42 + } elsif ($arg =~ /^-{1,2}help$/){
1.43 + help();
1.44 + exit 0;
1.45 + } elsif ($arg eq '--remove-duplicates'){
1.46 + $isRemoveDuplicates = 1;
1.47 + } elsif ($arg eq '--split-by-domens'){
1.48 + $isSplitByDomens = 1;
1.49 + } elsif ($arg =~ /--exclude-domen[=]{0,1}(\w*)/){
1.50 + $excludeDomen = $1;
1.51 + illegalUse() if $excludeDomen ne '' && $arg !~ /--exclude-domen=\w*/;
1.52 + $excludeDomen = shift(@ARGV) if $excludeDomen eq '';
1.53 + illegalUse() if $excludeDomen eq '';
1.54 + } else {
1.55 + illegalUse();
1.56 + }
1.57 } else {
1.58 - illegalUse();
1.59 + illegalUse() if $fileName ne '';
1.60 + $fileName = $arg;
1.61 }
1.62 - } else {
1.63 - illegalUse() if $fileName ne '';
1.64 - $fileName = $arg;
1.65 + $arg = shift(@ARGV);
1.66 + };
1.67 + if (!$isHasArgs) {
1.68 + about();
1.69 + exit 0;
1.70 }
1.71 - $arg = shift();
1.72 -};
1.73 -undef $arg;
1.74 -if (!$isHasArgs) {
1.75 - about();
1.76 - exit 0;
1.77 }
1.78 -processFile();
1.79
1.80 # Вывод информации о программе
1.81 sub about {