Devel::Peek::Dump is dumb as it always prints but getting the returned string back is not that easy. It's possible, though - but I'm not sure it's always helpful:
#! /usr/bin/perl use warnings; use strict; use feature qw{ say }; use experimental qw( signatures ); use Devel::Peek qw{ Dump }; sub _dump { my @failures; open my $olderr, '>&', \*STDERR or push @failures, $!; close *STDERR; open *STDERR, '>', \ my $err or push @failures, $!; eval { Dump($_[0]); 1 } or push @failures, $@; open *STDERR, '>&', $olderr or push @failures, $!; die @failures if @failures; my ($type) = $err =~ /FLAGS = \((.*)\)/; say $type; return $type } { my $c = 123; my $before = _dump($c); die unless $c < 130; say "II:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = 123; my $before = _dump($c); die unless $c lt 130; say "IP:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = 123; my $before = _dump($c); die unless $c < 130.01; say "IN:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = 123.01; my $before = _dump($c); die unless $c < 130; say "NI:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = 123.01; my $before = _dump($c); die unless $c lt '130'; say "NP:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = 123.01; my $before = _dump($c); die unless $c < 130.01; say "NN:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = '123'; my $before = _dump($c); die unless $c lt 130; say "PP:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = '123'; my $before = _dump($c); die unless $c < 130; say "PI:", $before eq _dump($c) ? 'Same' : 'Changed'; } { my $c = '123'; my $before = _dump($c); die unless $c < 130.01; say "PN:", $before eq _dump($c) ? 'Same' : 'Changed'; }

Output:

IOK,pIOK IOK,pIOK II:Same IOK,pIOK IOK,POK,pIOK,pPOK IP:Changed IOK,pIOK IOK,NOK,pIOK,pNOK IN:Changed NOK,pNOK NOK,pIOK,pNOK NI:Changed NOK,pNOK NOK,pNOK NP:Same NOK,pNOK NOK,pNOK NN:Same POK,IsCOW,pPOK POK,IsCOW,pPOK PP:Same POK,IsCOW,pPOK IOK,POK,IsCOW,pIOK,pPOK PI:Changed POK,IsCOW,pPOK NOK,POK,IsCOW,pNOK,pPOK PN:Changed

Note the "NP:Same" lines. Also, changing 130.01 to 130.0 makes a difference. What's even worse, changing the Perl version makes a difference. With 130.0, 5.26.1 gives "NN:Changed", but blead gives "NN:Same" (it doesn't add pIOK to NOK,pNOK).

I haven't succeeded in hiding the call to Dump in a tied or overloaded object.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: how watch a variable by choroba
in thread how watch a variable by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.