Perl Language Data::Show


Example

The function show is automatically exported when use Data::Show; is executed. This function takes a variable as its sole argument and it outputs:

  1. the name of the variable
  2. the contents of that variable (in a readable format)
  3. the line of the file that show is run from
  4. the file show is run from

Assuming that the following is code from the file example.pl:

use strict;
use warnings;
use Data::Show;

my @array = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

my %hash  = ( foo => 1, bar => { baz => 10, qux => 20 } );

my $href = \%hash;

show @array;
show %hash;
show $href;

perl example.pl gives the following output:

======(  @array  )=======================[ 'example.pl', line 11 ]======

    [1 .. 10]


======(  %hash  )========================[ 'example.pl', line 12 ]======

    { bar => { baz => 10, qux => 20 }, foo => 1 }


======(  $href  )========================[ 'example.pl', line 13 ]======

    { bar => { baz => 10, qux => 20 }, foo => 1 }

See the documentation for Data::Show.