package conf;
use Tie::File;

sub var_read
{
    my ($classname,$path)=@_;
    my ($self)={};
    bless($self,$classname);
    my @array;
    tie @array, 'Tie::File', $path,mode=>O_RDONLY;
    for(@array)
        {
        if(m/^(\s)*$/) {next;}
        if(m/^#/) {next;}
        chomp;
	if(/\[(.*)\]/) {$section=$1;next;}
        my @fields=split;
        $self->{"$section.$fields[0]"}=$fields[1];
        }
    untie @array;
#    close($conf_file);
    return $self;
}

sub get_binary
{
    my ($self,$n)=@_;
    my @array=();
    my $m;
    my $i;
    for $i (0..7)
    {
    $m=$n;
    $n=$n>>1;$n=$n<<1;
    $array[$i]=$m-$n;
    $n=$n>>1;
    }
return @array;
}

sub readable
{
    my ($self,$n)=@_;
    my $one,$two,$three;
    my $result=" ";
    $one=$n%1000;
    $two=(($n-$one)/1000)%1000;
    $three=($n-$one-$two*1000)/(1000*1000);
#    if($one==0) {$result="0";} elsif($one<10) {$result="00$one";} elsif($one<100) {$result="0$one";} else {$result=$result;}
#    if($two==0) {$result=$result;} elsif($two<10) {$result="00$two, $result";} elsif($two<100) {$result="0$two, $result";} else {$result="$two, $result";}
#    if($three==0) {$result=$result;} else {$result="$three, $result";}
    return "$three.$two.$one";
}

sub mb
{
    my ($self,$n)=@_;
    my $result;
    $result=$n/(1024*1024);
    $result=sprintf("%.2f", $result);
    return $result;
}

1;