#!/usr/bin/perl

http://surfin.infotel.bg:2000/wp/F_PRINT_REZ?ST=1&BR=236&CREG=1200&SEL=55155&p_CSURNAME=%C8%C2%C0%CD%CE%C2&p_CNAME=&p_CPATNAME=&CADDRESS=&p_flag_petch=t&p_flag_eq=t

$phones = 'SILISTRA';
$all    = 'ALL';
$back   = ' & ';

#                 SEL:CREG
%database = (
	SOFIA=>'68134:2800',
	PLOVDIV=>'56784:1500',
	BOURGAS=>'7079:200',
	VARNA=>'23:300',
	BLAGOEVGRAD=>'4279:100',
	VELIKO_TARNOVO=>'10447:400',
	VIDIN=>'10971:500',
	VRATSA=>'12259:600',
	SLIVEN=>'89:1900',
	SHUMEN=>'150:2600',
	GABROVO=>'2:66',
	DOBRICH=>'5:2300',
	KIUSTENDIL=>'41112:900',
	LOVECH=>'43952:1000',
	MONTANA=>'48489:1100',
	PAZARDZHIK=>'55155:1200'
	PERNIK=>'55871:1300',
	PLEVEN=>'56722:1400',
	RAZGRAD=>'10:1600',
	TARGOVISHTE=>'170:2400',
	SILISTRA=>'1:1800',
	RUSE=>'7000:1700'
);

%bukva = (
	10=>'À:a'  ,11=>'Á:b'  ,12=>'Â:v'  ,13=>'Ã:g'  ,14=>'Ä:d',
	15=>'Å:e'  ,16=>'Æ:zh' ,17=>'Ç:z'  ,18=>'È:i'  ,19=>'É:y',
	20=>'Ê:k'  ,21=>'Ë:l'  ,22=>'Ì:m'  ,23=>'Í:n'  ,24=>'Î:o',
	25=>'Ï:p'  ,26=>'Ð:r'  ,27=>'Ñ:s'  ,28=>'Ò:t'  ,29=>'Ó:u',
	30=>'Ô:f'  ,31=>'Õ:h'  ,32=>'Ö:c'  ,33=>'×:ch' ,34=>'Ø:sh',
	35=>'Ù:sht',36=>'Ú:xx' ,37=>'Ü:x'  ,38=>'Þ:iu' ,39=>'ß:ia'
);

$cnt = 0;
for ($i=10; $i<=39; $i=$i+5) {
    $arg[$cnt] = "$phones $database{$phones} ";
    for ($r= $i; $r <= $i+4; $r++) {
	$arg[$cnt] .= "$bukva{$r} ";
    };
    $arg[$cnt] .= "$all";
    $cnt++;
};

mkdir "$phones", 0755 || die "$!\n";
mkdir "$phones/parsed", 0755 || die "$!\n";

for ($i=0; $i<=5; $i++) {
    $exec = "./.download.pl $arg[$i] $back";
    system($exec);
};
