The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Primeval - terse variable dumping

VERSION

version 0.02

SYNOPSIS

    use Primeval;

    my $foo = 5;
    my @bar = 1..10;
    our %baz = (a => 1, b => 2);

    prim{eval} '$foo @bar %baz';

prints:

    $foo: 5
    @bar: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    %baz: {a => 1, b => 2}

EXPORT

    prim  # always called as prim{eval}

SUBROUTINES

prim{eval} LIST

takes a list of variable names, prints out the names along with their values. each element of the argument list is split on white-space.

while actually a subroutine named prim the block {eval} must always be passed to prim as the first argument. this code block is used to peek into the calling scope to fetch the values for lexical variables. using this code block to access the caller's scope allows this module to have no external dependencies (normally PadWalker would be required to peek into a lexical scope)

the arguments are checked to make sure they look like perl variable names, so you don't have to worry about anything accidentally making it into an eval that you wouldn't want to.

prim{eval} will normally only print the first level of an array or hash using a simple internal serialization routine. for full recursive printing, arrays and hashes can be passed to Data::Dumper by setting $Primeval::DUMP = 1

prim{eval} will return a string instead of printing if $Primeval::RETURN is set to a true value.

if you use prim{eval} in a subroutine with closed over variables, just make sure that you use every variable passed to prim{eval} somewhere else in the subroutine. otherwise, perl's garbage collector will sweep up the variables too early.

AUTHOR

Eric Strom, <asg at cpan.org>

BUGS

prim{eval} only works correctly with closures in perl 5.10+

please report any bugs or feature requests to bug-primeval at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Primeval. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

LICENSE AND COPYRIGHT

copyright 2011 Eric Strom.

this program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

see http://dev.perl.org/licenses/ for more information.