File: REF.pm

package info (click to toggle)
libdata-printer-perl 1.001000-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 732 kB
  • sloc: perl: 4,305; makefile: 7; sh: 1
file content (26 lines) | stat: -rw-r--r-- 556 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package Data::Printer::Filter::REF;
use strict;
use warnings;
use Data::Printer::Filter;
use Scalar::Util ();

filter 'REF' => \&parse;

sub parse {
    my ($ref, $ddp) = @_;

    my $string = '';
    # we only add the '\' if it's not an object
    if (!Scalar::Util::blessed($$ref) && (ref $$ref eq 'REF' || ref $$ref eq 'SCALAR' || ref $$ref eq 'VSTRING')) {
        $string .= '\\ ';
    }
    $string .= $ddp->parse($$ref);

    if ($ddp->show_tied and my $tie = ref tied $ref) {
        $string .= " (tied to $tie)";
    }

    return $string;
};

1;