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

📄 curia.pm

📁 harvest是一个下载html网页得机器人
💻 PM
📖 第 1 页 / 共 2 页
字号:
#sub sync {    my($self) = shift;    ($$self[1]) || return FALSE;    (scalar(@_) == 0) || return FALSE;    my($curia) = $handles{$$self[0]};    my($rv) = plcrsync($curia);    $errmsg = plcrerrmsg();    return $rv;}### $bool = $curia->optimize($bnum);# Method: Optimize the database.# `$bnum' specifies the number of the elements of the bucket array.  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.# In an alternating succession of deleting and storing with overwrite or concatenate,# dispensable regions accumulate.  This method is useful to do away with them.#sub optimize {    my($self) = shift;    ($$self[1]) || return FALSE;    my($bnum) = shift;    (defined($bnum)) || ($bnum = -1);    (scalar(@_) == 0) || return FALSE;    my($curia) = $handles{$$self[0]};    my($rv) = plcroptimize($curia, $bnum);    $errmsg = plcrerrmsg();    return $rv;}### $num = $curia->fsiz();# Method: Get the total size of the database files.# If successful, the return value is the total size of the database files, else, it is -1.#sub fsiz {    my($self) = shift;    ($$self[1]) || return -1;    (scalar(@_) == 0) || return -1;    my($curia) = $handles{$$self[0]};    my($rv) = plcrfsiz($curia);    $errmsg = plcrerrmsg();    return $rv;}### $num = $curia->bnum();# Method: Get the total number of the elements of each bucket array.# If successful, the return value is the total number of the elements of each bucket array,# else, it is -1.#sub bnum {    my($self) = shift;    ($$self[1]) || return -1;    (scalar(@_) == 0) || return -1;    my($curia) = $handles{$$self[0]};    my($rv) = plcrbnum($curia);    $errmsg = plcrerrmsg();    return $rv;}### $num = $curia->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($curia) = $handles{$$self[0]};    my($rv) = plcrrnum($curia);    $errmsg = plcrerrmsg();    return $rv;}### $bool = $curia->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($curia) = $handles{$$self[0]};    my($rv) = plcrwritable($curia);    $errmsg = plcrerrmsg();    return $rv;}### $bool = $curia->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($curia) = $handles{$$self[0]};    my($rv) = plcrfatalerror($curia);    $errmsg = plcrerrmsg();    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();}### $curia = tie(%hash, "Curia", $name, $omode, $bnum, $dnum);# Tying Function: TIEHASH: Get the database handle.#sub TIEHASH {    my($class, $name, $omode, $bnum, $dnum) = @_;    (defined($name)) || return undef();    (defined($omode)) || ($omode = OWRITER | OCREAT);    (defined($bnum)) || ($bnum = -1);    (defined($dnum)) || ($dnum = -1);    return $class->new($name, $omode, $bnum, $dnum);}### $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($curia) = $handles{$$self[0]};    if($$self[2]){        local($_) = $key;        $$self[2]();        $key = $_;    }    if($$self[3]){        local($_) = $val;        $$self[3]();        $val = $_;    }    my($rv) = plcrput($curia, $key, length($key), $val, length($val), DOVER);    ($rv == 0) && ($errmsg = plcrerrmsg());    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($curia) = $handles{$$self[0]};    if($$self[2]){        local($_) = $key;        $$self[2]();        $key = $_;    }    my($rv) = plcrout($curia, $key, length($key));    $errmsg = plcrerrmsg();    return $rv;}### $bool = (%hash = ());# Tying Function: CLEAR: Delete all records.#sub CLEAR {    my($self) = shift;    ($self->iterinit()) || return FALSE;    my($key);    while(defined($key = $self->iternext())){        ($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($curia) = $handles{$$self[0]};    if($$self[2]){        local($_) = $key;        $$self[2]();        $key = $_;    }    my($rv) = plcrget($curia, $key, length($key), 0, -1);    $errmsg = plcrerrmsg();    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->vsiz($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->iterinit()) || return undef();    return $self->iternext();}###: Called automatically by keys(), each(), and so on.# Tying Function: NEXTKEY: Get the next key.#sub NEXTKEY {    my($self) = shift;    return $self->iternext();}### $func = $curia->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 = $curia->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 = $curia->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 = $curia->filter_fetch_value(\&nf);# Method: set a filter invoked when reading a value.# `\&nf' specifies the reference 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 + -