{"id":6736,"date":"2022-12-20T19:33:33","date_gmt":"2022-12-20T22:33:33","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/datadumpfiltered-man3\/"},"modified":"2022-12-20T19:33:33","modified_gmt":"2022-12-20T22:33:33","slug":"datadumpfiltered-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/datadumpfiltered-man3\/","title":{"rendered":"Data::Dump::Filtered (man3)"},"content":{"rendered":"<h1 align=\"center\">Data::Dump::Filtered<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Data::Dump::Filtered \u2212 Pretty printing with filtering<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following functions are provided: <br \/> add_dump_filter( &#038;filter )<\/p>\n<p style=\"margin-left:17%;\">This registers a filter function to be used by the regular <b>Data::Dump::dump()<\/b> function. By default no filters are active.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Since registering filters has a global effect is might be more appropriate to use the <b>dump_filtered()<\/b> function instead.<\/p>\n<p style=\"margin-left:11%;\">remove_dump_filter( &#038;filter )<\/p>\n<p style=\"margin-left:17%;\">Unregister the given callback function as filter callback. This undoes the effect of add_filter.<\/p>\n<p style=\"margin-left:11%;\">dump_filtered(&#8230;, &#038;filter )<\/p>\n<p style=\"margin-left:17%;\">Works like <b>Data::Dump::dump()<\/b>, 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.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Any filters registered with <b>add_filter()<\/b> are ignored when this interface is invoked. Actually, passing &#8220;undef&#8221; as &#038;filter is allowed and &#8220;dump_filtered(&#8230;, undef)&#8221; is the official way to force unfiltered dumps.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Filter callback<\/b> <br \/> 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 &#8220;undef&#8221;.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">sub filter_callback { <br \/> my($ctx, $object_ref) = @_; <br \/> &#8230; <br \/> return { &#8230; } <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If the filter callback returns &#8220;undef&#8221; (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.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Filter context<\/b> <br \/> The context object provide methods that can be used to determine what kind of object is currently visited and where it\u2019s located. The context object has the following interface: <br \/> $ctx\u2212>object_ref<\/p>\n<p style=\"margin-left:17%;\">Alternative way to obtain a reference to the current object<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>class<\/p>\n<p style=\"margin-left:17%;\">If the object is blessed this return the class. Returns &#8220;&#8221; for objects not blessed.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>reftype<\/p>\n<p style=\"margin-left:17%;\">Returns what kind of object this is. It\u2019s a string like &#8221; <small>SCALAR&#8221;, &#8220;ARRAY&#8221;, &#8220;HASH&#8221;, &#8220;CODE&#8221;,&#8230;<\/small><\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>is_ref<\/p>\n<p style=\"margin-left:17%;\">Returns true if a reference was provided.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>is_blessed<\/p>\n<p style=\"margin-left:17%;\">Returns true if the object is blessed. Actually, this is just an alias for &#8220;$ctx\u2212>class&#8221;.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>is_array<\/p>\n<p style=\"margin-left:17%;\">Returns true if the object is an array<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>is_hash<\/p>\n<p style=\"margin-left:17%;\">Returns true if the object is a hash<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>is_scalar<\/p>\n<p style=\"margin-left:17%;\">Returns true if the object is a scalar (a string or a number)<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>is_code<\/p>\n<p style=\"margin-left:17%;\">Returns true if the object is a function (aka subroutine)<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>container_class<\/p>\n<p style=\"margin-left:17%;\">Returns the class of the innermost container that contains this object. Returns &#8220;&#8221; if there is no blessed container.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>container_self<\/p>\n<p style=\"margin-left:17%;\">Returns an textual expression relative to the container object that names this object. The variable $self in this expression is the container itself.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>object_isa( $class )<\/p>\n<p style=\"margin-left:17%;\">Returns <small>TRUE<\/small> if the current object is of the given class or is of a subclass.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>container_isa( $class )<\/p>\n<p style=\"margin-left:17%;\">Returns <small>TRUE<\/small> if the innermost container is of the given class or is of a subclass.<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>depth<\/p>\n<p style=\"margin-left:17%;\">Returns how many levels deep have we recursed into the structure (from the original <b>dump_filtered()<\/b> arguments).<\/p>\n<p style=\"margin-left:11%;\">$ctx\u2212>expr <br \/> $ctx\u2212>expr( $top_level_name )<\/p>\n<p style=\"margin-left:17%;\">Returns an textual expression that denotes the current object. In the expression $var is used as the name of the top level object dumped. This can be overridden by providing a different name as argument.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Filter return hash<\/b> <br \/> The following elements has significance in the returned hash: <br \/> dump => $string<\/p>\n<p style=\"margin-left:17%;\">incorporate the given string as the representation for the current value<\/p>\n<p style=\"margin-left:11%;\">object => $value<\/p>\n<p style=\"margin-left:17%;\">dump the given value instead of the one visited and passed in as $object. Basically the same as specifying &#8220;dump => Data::Dump::dump($value)&#8221;.<\/p>\n<p style=\"margin-left:11%;\">comment => $comment<\/p>\n<p style=\"margin-left:17%;\">prefix the value with the given comment string<\/p>\n<p style=\"margin-left:11%;\">bless => $class<\/p>\n<p style=\"margin-left:17%;\">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\u2019t blessed at all.<\/p>\n<p style=\"margin-left:11%;\">hide_keys => [\u2019key1\u2019, \u2019key2\u2019,&#8230;] <br \/> hide_keys => &#038;code<\/p>\n<p style=\"margin-left:17%;\">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.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Data::Dump<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Data::Dump::Filtered \u2212 Pretty printing with filtering <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3110,3007],"class_list":["post-6736","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-datadumpfiltered","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6736"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6736\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}