⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 villa.pm

📁 harvest是一个下载html网页得机器人
💻 PM
📖 第 1 页 / 共 2 页
字号:
# $bool = $villa->settuning($lrecmax, $nidxmax, $lcnum, $ncnum);# Method: Set alignment of the database handle.# `$lrecmax' specifies the max number of records in a leaf node of B+ tree.  If it is undef or# not more than 0, the default value is specified.# `$nidxmax' specifies the max number of indexes in a non-leaf node of B+ tree.  If it is undef# or not more than 0, the default value is specified.# `$lcnum' specifies the max number of caching leaf nodes.  If it is undef or not more than 0,# the default value is specified.# `$ncnum' specifies the max number of caching non-leaf nodes.  If it is undef or not more than# 0, the default value is specified.# If successful, the return value is true, else, it is false.# The default setting is equivalent to `vlsettuning(49, 192, 1024, 512)'.  Because tuning# paremeters are not saved in a database, you should specify them every opening a database.#sub settuning {    my($self) = shift;    ($$self[1]) || return FALSE;    my($lrecmax) = shift;    my($nidxmax) = shift;    my($lcnum) = shift;    my($ncnum) = shift;    (defined($lrecmax)) || ($lrecmax = -1);    (defined($nidxmax)) || ($nidxmax = -1);    (defined($lcnum)) || ($lcnum = -1);    (defined($ncnum)) || ($ncnum = -1);    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    plvlsettuning($villa, $lrecmax, $nidxmax, $lcnum, $ncnum);    return TRUE;}### $bool = $villa->sync();# Method: Synchronize updating contents with the file and the device.# If successful, the return value is true, else, it is false.# This method is useful when another process uses the connected database file.  This method# shuold not be used while the transaction is activated.#sub sync {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvlsync($villa);    $errmsg = plvlerrmsg();    return $rv;}### $bool = $villa->optimize($bnum);# Method: Optimize the database.# If successful, the return value is true, else, it is false.# In an alternating succession of deleting and storing with overwrite or concatenate,# dispensable regions accumulate.  This method is useful to do away with them.  This method# shuold not be used while the transaction is activated.#sub optimize {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvloptimize($villa);    $errmsg = plvlerrmsg();    return $rv;}### $num = $villa->fsiz();# Method: Get the size of the database file.# If successful, the return value is the size of the database file, else, it is -1.# Because of the I/O buffer, the return value may be less than the real size.#sub fsiz {    my($self) = shift;    ($$self[1]) || return -1;    (scalar(@_) == 0) || return -1;    my($villa) = $handles{$$self[0]};    my($rv) = plvlfsiz($villa);    $errmsg = plvlerrmsg();    return $rv;}### $num = $villa->rnum();# Method: Get the number of the records stored in the database.# If successful, the return value is the number of the records stored in the database, else,# it is -1.#sub rnum {    my($self) = shift;    ($$self[1]) || return -1;    (scalar(@_) == 0) || return -1;    my($villa) = $handles{$$self[0]};    my($rv) = plvlrnum($villa);    $errmsg = plvlerrmsg();    return $rv;}### $bool = $villa->writable();# Method: Check whether the database handle is a writer or not.# The return value is true if the handle is a writer, false if not.#sub writable {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvlwritable($villa);    $errmsg = plvlerrmsg();    return $rv;}### $bool = $villa->fatalerror();# Method: Check whether the database has a fatal error or not.# The return value is true if the database has a fatal error, false if not.#sub fatalerror {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvlfatalerror($villa);    $errmsg = plvlerrmsg();    return $rv;}### $bool = $villa->tranbegin();# Method: Begin the transaction.# If successful, the return value is true, else, it is false.# Only one transaction can be activated with a database handle at the same time.#sub tranbegin {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvltranbegin($villa);    $errmsg = plvlerrmsg();    return $rv;}### $bool = $villa->trancommit();# Method: Commit the transaction.# If successful, the return value is true, else, it is false.# Updating a database in the transaction is fixed when it is committed successfully.#sub trancommit {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvltrancommit($villa);    $errmsg = plvlerrmsg();    return $rv;}### $bool = $villa->tranabort();# Method: Abort the transaction.# If successful, the return value is true, else, it is false.# Updating a database in the transaction is discarded when it is aborted.  The state of the# database is rollbacked to before transaction.#sub tranabort {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($villa) = $handles{$$self[0]};    my($rv) = plvltranabort($villa);    $errmsg = plvlerrmsg();    return $rv;}###: Called automatically by the garbage collector.# Destructor: DESTROY: Release the resources.# If the database handle is not closed yet, it is closed.#sub DESTROY {    my($self) = shift;    $self->close();}### $villa = tie(%hash, "Villa", $name, $omode, $cmp);# Tying Function: TIEHASH: Get the database handle.#sub TIEHASH {    my($class, $name, $omode, $cmp) = @_;    (defined($name)) || return undef();    (defined($omode)) || ($omode = OWRITER | OCREAT);    return $class->new($name, $omode, $cmp);}### $bool = ($hash{$key} = $val);# Tying Function: STORE: Store a record with overwrite.#sub STORE {    my($self, $key, $val) = @_;    ($$self[1]) || return FALSE;    (defined($key) && defined($val)) || return FALSE;    my($villa) = $handles{$$self[0]};    if($$self[2]){        local($_) = $key;        $$self[2]();        $key = $_;    }    if($$self[3]){        local($_) = $val;        $$self[3]();        $val = $_;    }    my($rv) = plvlput($villa, $key, length($key), $val, length($val), DOVER);    ($rv == 0) && ($errmsg = plvlerrmsg());    return $rv;}### $bool = delete($hash{$key});# Tying Function: DELETE: Delete a record.#sub DELETE {    my($self, $key) = @_;    ($$self[1]) || return FALSE;    (defined($key)) || return FALSE;    my($villa) = $handles{$$self[0]};    if($$self[2]){        local($_) = $key;        $$self[2]();        $key = $_;    }    my($rv) = plvlout($villa, $key, length($key));    $errmsg = plvlerrmsg();    return $rv;}### $bool = (%hash = ());# Tying Function: CLEAR: Delete all records.#sub CLEAR {    my($self) = shift;    my($key);    while($self->curfirst()){        ($key = $self->curkey()) || return FALSE;        ($self->out($key)) || return FALSE;    }    return TRUE;}### $str = $hash{$key};# Tying Function: FETCH: Retrieve whole value of a record.#sub FETCH {    my($self, $key) = @_;    ($$self[1]) || return undef();    (defined($key)) || return undef();    my($villa) = $handles{$$self[0]};    if($$self[2]){        local($_) = $key;        $$self[2]();        $key = $_;    }    my($rv) = plvlget($villa, $key, length($key));    $errmsg = plvlerrmsg();    if($rv && $$self[5]){        local($_) = $rv;        $$self[5]();        $rv = $_;    }    return $rv;}### $bool = exists($hash{$val});# Tying Function: EXISTS: Check whether a record exists or not.#sub EXISTS {    my($self) = shift;    my($key) = shift;    return $self->vnum($key) > 0 ? TRUE : FALSE;}###: Called automatically by keys(), each(), and so on.# Tying Function: FIRSTKEY: Get the first key.#sub FIRSTKEY {    my($self) = shift;    ($self->curfirst()) || return undef();    return $self->curkey();}###: Called automatically by keys(), each(), and so on.# Tying Function: NEXTKEY: Get the next key.#sub NEXTKEY {    my($self) = shift;    ($self->curnext()) || return undef();    return $self->curkey();}### $func = $villa->filter_store_key(\&nf);# Method: set a filter invoked when writing a key.# `\&nf' specifies the reference of a filter function proofing `$_'.  If it is undef, the# current filter function is cleared.# The return value is the old filter function.#sub filter_store_key {    my($self) = shift;    my($nf) = shift;    my($of) = $$self[2];    $$self[2] = $nf;    return $of;}### $func = $villa->filter_store_value(\&nf);# Method: set a filter invoked when writing a value.# `\&nf' specifies the reference of a filter function proofing `$_'.  If it is undef, the# current filter function is cleared.# The return value is the old filter function.#sub filter_store_value {    my($self) = shift;    my($nf) = shift;    my($of) = $$self[3];    $$self[3] = $nf;    return $of;}### $func = $villa->filter_fetch_key(\&nf);# Method: set a filter invoked when reading a key.# `\&nf' specifies the reference of a filter function proofing `$_'.  If it is undef, the# current filter function is cleared.# The return value is the old filter function.#sub filter_fetch_key {    my($self) = shift;    my($nf) = shift;    my($of) = $$self[4];    $$self[4] = $nf;    return $of;}### $func = $villa->filter_fetch_value(\&nf);# Method: set a filter invoked when reading a value.# `\&nf' specifies the reference of a filter function proofing `$_'.  If it is undef, the# current filter function is cleared.# The return value is the old filter function.#sub filter_fetch_value {    my($self) = shift;    my($nf) = shift;    my($of) = $$self[5];    $$self[5] = $nf;    return $of;}TRUE;                                    # return success code# END OF FILE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -