5 my $fileName; |
5 my $fileName; |
6 my $isRemoveDuplicates = 0; |
6 my $isRemoveDuplicates = 0; |
7 my $isSplitByDomens = 0; |
7 my $isSplitByDomens = 0; |
8 my $excludeDomen; |
8 my $excludeDomen; |
9 |
9 |
10 # Парсим параметры командной строки |
10 parseCommandLine(); |
11 my $arg = shift(); |
11 processFile(); |
12 my $isHasArgs = 0; |
12 exit 0; |
13 until ($arg eq '') { |
13 |
14 $isHasArgs = 1; |
14 # Парсер параметров командной строки |
15 if($arg =~ /^-{1,2}.+$/){ |
15 sub parseCommandLine { |
16 if ($arg =~ /^-{1,2}version$/){ |
16 my $arg = shift(@ARGV); |
17 about(); |
17 my $isHasArgs = 0; |
18 exit 0; |
18 until ($arg eq '') { |
19 } elsif ($arg =~ /^-{1,2}help$/){ |
19 $isHasArgs = 1; |
20 help(); |
20 if($arg =~ /^-{1,2}.+$/){ |
21 exit 0; |
21 if ($arg =~ /^-{1,2}version$/){ |
22 } elsif ($arg eq '--remove-duplicates'){ |
22 about(); |
23 $isRemoveDuplicates = 1; |
23 exit 0; |
24 } elsif ($arg eq '--split-by-domens'){ |
24 } elsif ($arg =~ /^-{1,2}help$/){ |
25 $isSplitByDomens = 1; |
25 help(); |
26 } elsif ($arg =~ /--exclude-domen[=]{0,1}(\w*)/){ |
26 exit 0; |
27 $excludeDomen = $1; |
27 } elsif ($arg eq '--remove-duplicates'){ |
28 illegalUse() if $excludeDomen ne '' && $arg !~ /--exclude-domen=\w*/; |
28 $isRemoveDuplicates = 1; |
29 $excludeDomen = shift() if $excludeDomen eq ''; |
29 } elsif ($arg eq '--split-by-domens'){ |
30 illegalUse() if $excludeDomen eq ''; |
30 $isSplitByDomens = 1; |
|
31 } elsif ($arg =~ /--exclude-domen[=]{0,1}(\w*)/){ |
|
32 $excludeDomen = $1; |
|
33 illegalUse() if $excludeDomen ne '' && $arg !~ /--exclude-domen=\w*/; |
|
34 $excludeDomen = shift(@ARGV) if $excludeDomen eq ''; |
|
35 illegalUse() if $excludeDomen eq ''; |
|
36 } else { |
|
37 illegalUse(); |
|
38 } |
31 } else { |
39 } else { |
32 illegalUse(); |
40 illegalUse() if $fileName ne ''; |
|
41 $fileName = $arg; |
33 } |
42 } |
34 } else { |
43 $arg = shift(@ARGV); |
35 illegalUse() if $fileName ne ''; |
44 }; |
36 $fileName = $arg; |
45 if (!$isHasArgs) { |
|
46 about(); |
|
47 exit 0; |
37 } |
48 } |
38 $arg = shift(); |
|
39 }; |
|
40 undef $arg; |
|
41 if (!$isHasArgs) { |
|
42 about(); |
|
43 exit 0; |
|
44 } |
49 } |
45 processFile(); |
|
46 |
50 |
47 # Вывод информации о программе |
51 # Вывод информации о программе |
48 sub about { |
52 sub about { |
49 my $about = q { |
53 my $about = q { |
50 E-mail filter tool for Aptech |
54 E-mail filter tool for Aptech |