Data-Show-0.002003/000755 000765 000765 00000000000 12603641606 013115 5ustar00damian000000 000000 Data-Show-0.002003/Build.PL000644 000765 000765 00000000712 11423654262 014412 0ustar00damian000000 000000 use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'Data::Show', license => 'perl', dist_author => 'Damian Conway ', dist_version_from => 'lib/Data/Show.pm', requires => { 'Test::More' => 0, 'Data::Dump' => 1.17, 'version' => 0, }, add_to_cleanup => [ 'Data-Show-*' ], ); $builder->create_build_script(); Data-Show-0.002003/Changes000644 000765 000765 00000001563 12603641605 014414 0ustar00damian000000 000000 Revision history for Data-Show 0.0.1 Fri Mar 5 06:38:03 2010 Initial release. 0.001001 Tue Jun 22 06:14:58 2010 No changes logged 0.001002 Sun Oct 10 19:04:25 2010 - Patched distribution to track changes in Data::Dump 1.17 (thanks Christopher) - Improved recognition of hashes and arrays at the end of a block 0.001_003 Sun Oct 31 07:36:19 2010 - Improved recognition of q/qq/qr/etc. 0.001_004 Sat Feb 19 08:13:46 2011 - Fixed test suite to work correctly with long doubles (thanks Andreas!) 0.002001 Fri Jan 20 17:45:43 2012 - Fixed annoying flattening of show(%hash) construct (thanks Salvatore!) 0.002002 Tue Oct 22 10:20:04 2013 - Refixed annoying flattening - Fixed problems with 5.18 (thanks John) 0.002003 Sat Oct 3 12:55:01 2015 - Fixed handling of %+ (thanks Steve!) Data-Show-0.002003/lib/000755 000765 000765 00000000000 12603641606 013663 5ustar00damian000000 000000 Data-Show-0.002003/Makefile.PL000644 000765 000765 00000001030 11423654250 015057 0ustar00damian000000 000000 use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Data::Show', AUTHOR => 'Damian Conway ', VERSION_FROM => 'lib/Data/Show.pm', ABSTRACT_FROM => 'lib/Data/Show.pm', PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Data::Dump' => 1.17, 'version' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Data-Show-*' }, ); Data-Show-0.002003/MANIFEST000644 000765 000765 00000000403 12603641606 014243 0ustar00damian000000 000000 Build.PL Changes MANIFEST Makefile.PL README lib/Data/Show.pm t/00.load.t t/pod.t t/show.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Data-Show-0.002003/META.json000644 000765 000765 00000001704 12603641606 014540 0ustar00damian000000 000000 { "abstract" : "Dump data structures with name and point-of-origin", "author" : [ "Damian Conway " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.142690", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Data-Show", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Data::Dump" : "1.17", "Test::More" : "0", "version" : "0" } } }, "release_status" : "stable", "version" : "0.002003" } Data-Show-0.002003/META.yml000644 000765 000765 00000001060 12603641606 014363 0ustar00damian000000 000000 --- abstract: 'Dump data structures with name and point-of-origin' author: - 'Damian Conway ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.142690' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Data-Show no_index: directory: - t - inc requires: Data::Dump: '1.17' Test::More: '0' version: '0' version: '0.002003' Data-Show-0.002003/README000644 000765 000765 00000001041 12603641605 013770 0ustar00damian000000 000000 Data::Show version 0.002003 Wrapper around Data::Dump to provide better context information INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install Alternatively, to install with Module::Build, you can use the following commands: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES None. COPYRIGHT AND LICENCE Copyright (C) 2010, Damian Conway This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Data-Show-0.002003/t/000755 000765 000765 00000000000 12603641606 013360 5ustar00damian000000 000000 Data-Show-0.002003/t/00.load.t000644 000765 000765 00000000162 11344006033 014667 0ustar00damian000000 000000 use Test::More tests => 1; BEGIN { use_ok( 'Data::Show' ); } diag( "Testing Data::Show $Data::Show::VERSION" ); Data-Show-0.002003/t/pod.t000644 000765 000765 00000000214 11344006033 014312 0ustar00damian000000 000000 #!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Data-Show-0.002003/t/show.t000644 000765 000765 00000004203 12603641525 014524 0ustar00damian000000 000000 use Data::Show; use Test::More 'no_plan'; my $STDERR; close STDERR; open *STDERR, '>', \$STDERR or die $!; my %foo = (foo => 1, food => 2, fool => 3, foop => 4, foon => [5..10]); my @bar = qw; my $baz = 'baz'; my $ref = \@bar; sub sq; show(%foo); show $/; show @bar; show ( @bar, $baz, ); show $baz; show $ref; show @bar[do{1..2;}]; show 2*3; show 'a+b'; show 100 * sq length $baz; show $foo{q[;{{{]}; do { show 'foo' ~~ m/;{\/{/ }; show $/{Answer}; my $str = 'foo'; $str =~ m/(?\w+)/; show $+{bar}; my @expected = ; my @got = split "(?<=\n)", $STDERR; for my $n (0..$#expected) { if ($expected[$n] =~ m{\A \s* \{ }xms) { is_deeply(eval($got[$n]), eval($expected[$n]) => ": $expected[$n]"); } else { is $got[$n], $expected[$n] => ": $expected[$n]"; } } sub sq { my ($n) = @_; return $n * $n; } __DATA__ ======( %foo )=============================[ 'show.t', line 13 ]====== { foo => 1, food => 2, fool => 3, foon => [5 .. 10], foop => 4 } ======( $/ )===============================[ 'show.t', line 14 ]====== "\n" ======( @bar )=============================[ 'show.t', line 15 ]====== ["b", "a", "r"] ======( @bar, $baz, )======================[ 'show.t', line 16 ]====== ("b", "a", "r", "baz") ======( $baz )=============================[ 'show.t', line 20 ]====== "baz" ======( $ref )=============================[ 'show.t', line 21 ]====== ["b", "a", "r"] ======( @bar[do{1..2;}] )==================[ 'show.t', line 22 ]====== ("a", "r") ======( 2*3 )==============================[ 'show.t', line 23 ]====== 6 ======( 'a+b' )============================[ 'show.t', line 24 ]====== "a+b" ======( 100 * sq length $baz )=============[ 'show.t', line 25 ]====== 900 ======( $foo{q[;{{{]} )====================[ 'show.t', line 26 ]====== undef ======( 'foo' ~~ m/;{\/{/ )================[ 'show.t', line 28 ]====== "" ======( $/{Answer} )=======================[ 'show.t', line 30 ]====== undef ======( $+{bar} )==========================[ 'show.t', line 34 ]====== "foo" Data-Show-0.002003/lib/Data/000755 000765 000765 00000000000 12603641606 014534 5ustar00damian000000 000000 Data-Show-0.002003/lib/Data/Show.pm000644 000765 000765 00000021254 12603641605 016015 0ustar00damian000000 000000 package Data::Show; use warnings; use strict; use Data::Dump 'dump'; use 5.010; our $VERSION = '0.002003'; # Unconditionally export show()... sub import { no strict 'refs'; *{caller().'::show'} = \&show; } # Useful patterns... my $IDENT = qr{ [^\W\d]\w* (?: :: [^\W\d]\w* )* | [_\W] }xms; use re 'eval'; my $CODE = qr{ (?&CODE_FRAGMENT) (?(DEFINE) (? (?: (?"ED) | \b (?: q[qxr]?+ | [msy] | tr ) \s* (?&DELIMITED) | (?&NESTED) | [%\$\@] (?: (?&BRACE_DELIMS) | $IDENT) (?&NESTED)? | [^][{}()"'`;] )++ ) (? (?: (?"ED) | \b (?: q[qxr]?+ | [msy] | tr ) \s* (?&DELIMITED) | (?&NESTED) | [^][{}()"'`] )++ ) (? " [^\\"]++ (?: \\. [^\\"]++ )* " | ' [^\\']++ (?: \\. [^\\']++ )* ' | ` [^\\`]++ (?: \\. [^\\`]++ )* ` | / [^\\/]++ (?: \\. [^\\/]++ )* / | \? [^\\?]++ (?: \\. [^\\?]++ )* \? ) (? (?&BRACE_DELIMS) | (?&PAREN_DELIMS) | (?&ANGLE_DELIMS) | (?&SQUARE_DELIMS) | \s++ (?\w) (?:\\.|(?!\g{DELIM_W}).)*+ \g{DELIM_W} | (?[^\w\s]) (?:\\.|(?!\g{DELIM_S}).)*+ \g{DELIM_S} ) (? \( (?&NESTED_CODE_FRAGMENT) \) | \[ (?&NESTED_CODE_FRAGMENT) \] | \{ (?&NESTED_CODE_FRAGMENT) \} | \< (?&NESTED_CODE_FRAGMENT) \> ) (? \{ (?: [^{}] | \\. | (?&BRACE_DELIMS) )*+ \} ) (? \( (?: [^()] | \\. | (?&PAREN_DELIMS) )*+ \) ) (? \< (?: [^<>] | \\. | (?&ANGLE_DELIMS) )*+ \> ) (? \[ (?: [^][] | \\. | (?&SQUARE_DELIMS) )*+ \] ) ) }xms; # Configuration for layout of representation... my $DEFAULT_INDENT = 4; my $MAX_WIDTH = 72; my $TITLE_POS = 6; # Be a ninja... our @CARP_NOT; # The whole point of the module... sub show { # Determine context... my (undef, $file, $line) = caller(); # Extract description of arglist from context... my ( $desc, $context ); if (open my $fh, '<', $file) { for (1..$line-1) { readline($fh) // last } $desc = do { local $/; readline $fh; }; } { # local-ize %+ to avoid clobbering any values with regexes below... local %+; # Trim filename and format context info and description... $file =~ s{.*[/\\]}{}xms; $context = "'$file', line $line"; $desc //= $context; # Isolate arg list and compress internal whitespace... $desc =~ s{ \A (?: (?!\bshow) . )*? \b show \b \s* ($CODE) \s* (?: [;\}] .* | \Z ) }{$1}xms; $desc =~ s{\A \( | \) \Z}{}gxms; $desc =~ s{\s+}{ }gxms; } # Serialize Contextual::Return::Value objects (which break dump())... for my $arg (@_) { if ((ref($arg)||q{}) =~ m{\A Contextual::Return}xms) { require Contextual::Return; Contextual::Return::FREEZE($arg); } } # Serialize argument (restoring it, if it was inappropriately flattened)... my $representation = $desc =~ m{ \A \@ $IDENT \s* \Z }xms ? dump(\@_ ) : $desc =~ m{ \A \% $IDENT \s* \Z }xms ? dump({@_}) : dump( @_ ); # Indent representation wrt heading... $representation =~ s{^}{ q{ } x $DEFAULT_INDENT }gxmse; # Clean up parens around title... $desc =~ s{ \A \s* (?| \( \s* (.*?) \s* \) | \s* (.*?) \s* ) \Z } {( $1 )}xms; # Insert title into header... my $header = '=' x $MAX_WIDTH; substr($header, $TITLE_POS, length($desc), $desc); # Add context if it isn't just context... if ($desc ne "( $context )") { $context = "[ $context ]"; substr($header, -length($context)-$TITLE_POS, -$TITLE_POS, $context); } # Display data... print {*STDERR} "$header\n\n$representation\n\n\n"; return; } 1; # Magic true value required at end of module __END__ =head1 NAME Data::Show - Dump data structures with name and point-of-origin =head1 VERSION This document describes Data::Show version 0.002003 =head1 SYNOPSIS use Data::Show; show %foo; show @bar; show ( @bar, $baz, ); show $baz; show $ref; show @bar[do{1..2;}]; show 2*3; show 'a+b'; show 100 * sqrt length $baz; show $foo{q[;{{{]}; =head1 DESCRIPTION This module provides a simple wrapper around the Data::Dump module. A call to C data-dumps its arguments, prefaced by a divider line that reports the arguments and the file and line from which C was called. For example, the code in the L would produce something like: ======( %foo )========================[ 'demo.pl', line 11 ]====== { foo => 1, food => 'b', foon => [3, 4, 5, 6, 7, 8, 9, 10] } ======( @bar )========================[ 'demo.pl', line 12 ]====== ["b", "a", "r"] ======( @bar, $baz, )=================[ 'demo.pl', line 13 ]====== ("b", "a", "r", "baz") ======( $baz )========================[ 'demo.pl', line 17 ]====== "baz" ======( $ref )========================[ 'demo.pl', line 18 ]====== ["b", "a", "r"] ======( @bar[do{1..2;}] )=============[ 'demo.pl', line 19 ]====== ("a", "r") ======( 2*3 )=========================[ 'demo.pl', line 20 ]====== 6 ======( 'a+b' )=======================[ 'demo.pl', line 21 ]====== "a+b" ======( 100 * sqrt length $baz )======[ 'demo.pl', line 22 ]====== "173.205080756888" ======( $foo{q[;{{{]} )===============[ 'demo.pl', line 23 ]====== undef ======( 'foo' ~~ m/;{\/{/ )===========[ 'demo.pl', line 25 ]====== "" =head1 INTERFACE =over =item C This is the only subroutine provided by the module. It is always exported. C can be called with any number of arguments and data-dumps them all with a suitable header indicating the arguments' names, and the file and line from which C was called. C does not return a useful value. =back =head1 DIAGNOSTICS None, apart from those provided by Data::Dump; =head1 CONFIGURATION AND ENVIRONMENT Data::Show requires no configuration files or environment variables. =head1 DEPENDENCIES Only works under Perl 5.10 and later. Requires the Data::Dump module. =head1 INCOMPATIBILITIES None reported. =head1 BUGS AND LIMITATIONS Uses sophisticated regexes to parse out the argument list from the source. Hence subject to the usual limitations of this technique (namely, that it may get the argument list wrong occasionally). No bugs have been reported. Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Damian Conway C<< >> =head1 LICENCE AND COPYRIGHT Copyright (c) 2010, Damian Conway C<< >>. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L. =head1 DISCLAIMER OF WARRANTY BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.