SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE


YUM REPOSITORY

 
 

MAN page from Fedora 28 perl-Data-Dumper-Names-0.03-27.fc28.noarch.rpm

Data::Dumper::Names

Section: User Contributed Perl Documentation (3)
Updated: 2018-02-08
Index 

NAME

Data::Dumper::Names - Dump variables with names (no source filter) 

VERSION

Version 0.03 

SYNOPSIS

    use Data::Dumper::Names;    my $foo = 3;    my @bar = qw/this that/;    warn Dumper($foo, \@bar);    __END__    output:        $foo = 3;    @bar = (        'this',        'that'    );
 

EXPORT

Like Data::Dumper, this module automatically exports "Dumper()"unless a null import list is explicitly stated.

This module should be considered ALPHA. 

FUNCTIONS

 

Dumper

 warn Dumper($foo, \@bar);

"Dumper" returns a string like "Dumper" but the variable names are prefixedfor you. Unlike Data::Dumper::Simple, arrays and hashes must be passed byreference. 

CAVEATS

 

PadWalker

This module is an alternative to Data::Dumper::Simple. Many people likethe aforementioned module but do not like the fact that it uses a sourcefilter. In order to pull off the trick with this module, we use PadWalker.This introduces its own set of problems, not the least of which is thatPadWalker uses undocumented features of the Perl internals and has anannoying tendency to break. Thus, if this module doesn't work on yourmachine you may have to go back to Data::Dumper::Simple. 

References

Arrays and hashes, unlike in Data::Dumper::Simple, must be passed byreference. Unfortunately, this causes a problem:

 my $foo = \@array; warn Dumper( $foo, \@array );

Because of how pads work, there is no easy way to disambiguate between thesetwo variables. Thus, "Dumper" may identify them as $foo or it mayidentify them as @array. If it misidentifies them, it should at least doso consistently for the individual call to "Dumper". (For Perl 5.8 andafter, subsequent calls to "Dumper" may have different results in the abovecase. This is because of how Perl handles hash ordering). 

Call stack level

You generally will call things with this:

 warn Dumper($foo, $bar, \@baz);

However, you might be refactoring code and want to shove that into asubroutine somewhere. In that case, you'll need to set (via "local"!), the$Data::Dumper::Names::UpLevel variable. It defaults to one, but you might setit to a higher level, depending on how high up the call stack those variablesare really located:

 sub show {     return unless $ENV{VERBOSE};     local $Data::Dumper::Names::UpLevel = 2;     warn Dumper(@_); }

Note that if you fail to use "local", subsequent calls to "Dumper" may belooking at the wrong call stack level. 

Unknown Variables

The easiest way to have things ``just work'' is to make sure that you cansee the name of the variable in the "Dumper" call:

 warn Dumper($foo, \@bar); # good warn Dumper($_);          # probably will get output like $VAR1 = ... warn Dumper($bar[2]);     # probably will get output like $VAR1 = ...

Usually the output from Dumper will be something like this:

 $foo = 3; @bar = (    'this',    'that' );

However, sometimes a $VAR1 or $VAR2 will creep in there. This happensif pass in anything but a named variable. For example:

 warn Dumper( $bar[2] ); # $VAR1 = ... can't figure out the name

We probably won't be able to figure out the name of the variable directlyunless we took the time to walk all data structures in scope at the time"Dumper" is called. This is an expensive proposition, so we don't do that.It's possible we will be able to figure out that name, but only if thevariable was assigned its value from a reference to a named variable.

 $bar[2] = \%foo; warn Dumper( $bar[2] );

"Dumper", in the above example, will identify that variable as being %foo.That could be confusing if those lines are far apart.

 foreach ( @customer ) {    print Dumper( $_ ); }

It should go without saying that the above will also probably not be able toname the variables. 

AUTHOR

Curtis ``Ovid'' Poe, "<ovidAATTcpan.org>" 

BUGS

Please report any bugs or feature requests to"bug-data-dumper-namesAATTrt.cpan.org", or through the web interface at<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Dumper-Names>.I will be notified, and then you'll automatically be notified of progress onyour bug as I make changes. 

ACKNOWLEDGEMENTS

See Data::Dumper and Data::Dumper::Simple.

Thanks to demerphq (Yves Orton) for finding a bug in how some variable namesare reported. See Changes for details. 

COPYRIGHT & LICENSE

Copyright 2005 Curtis ``Ovid'' Poe, all rights reserved.

This program is free software; you can redistribute it and/or modify itunder the same terms as Perl itself.


 

Index

NAME
VERSION
SYNOPSIS
EXPORT
FUNCTIONS
Dumper
CAVEATS
PadWalker
References
Call stack level
Unknown Variables
AUTHOR
BUGS
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE

This document was created byman2html,using the manual pages.