Devel-ArgNames-0.03/0000755000076500007650000000000010736732567017110 5ustar nothingmuchnothingmuch00000000000000Devel-ArgNames-0.03/lib/0000755000076500007650000000000010736732565017654 5ustar nothingmuchnothingmuch00000000000000Devel-ArgNames-0.03/lib/Devel/0000755000076500007650000000000010736732565020713 5ustar nothingmuchnothingmuch00000000000000Devel-ArgNames-0.03/lib/Devel/ArgNames.pm0000644000076500007650000000367010736732427022751 0ustar nothingmuchnothingmuch00000000000000#!/usr/bin/perl package Devel::ArgNames; use strict; use warnings; our $VERSION = "0.03"; use base qw(Exporter); our @EXPORT_OK = our @EXPORT = qw(arg_names); use PadWalker qw(peek_my peek_our); sub arg_names (;$) { my $level = shift || 2; { package DB; () = caller($level - 1) } @{{ reverse %{peek_my($level)}, %{peek_our($level)} }}{\(@DB::args)}; } __PACKAGE__ __END__ =pod =head1 NAME Devel::ArgNames - Figure out the names of variables passed into subroutines. =head1 SYNOPSIS use Devel::ArgNames; sub foo { warn "foo() called with arguments: " . join(", ", map { defined() ? $_ : "" } arg_names(@_) ); } foo($bar, $gorch, $blah[4]); =head1 DESCRIPTION When print-debugging code, you will often ind yourself going: print "\$foo is $foo, \$bar is $bar" With this module, you can write a reusable subroutine easily: sub my_print_vars { my %vars; @vars{arg_names()} = @_; foreach my $var ( keys %vars ) { warn "$var is $vars{$var}\n"; } } my_print_vars($foo, $bar); This module doesn't provide dumping facilities because there are too many to choose from. This is a DIY kit ;-) =head1 EXPORTS =over 4 =item arg_names [ $level ] This function will return the names associated with the variables found on C<@_>, at the level $level. If C<$level> is not provided C's caller's caller will be used (C<$level == 2> in that case). =back =head1 VERSION CONTROL This module is maintained using Darcs. You can get the latest version from L, and use C to commit changes. =head1 SEE ALSO L, L, L, L, L. =head1 AUTHORS Ran Eilam Yuval Kogman Enothingmuch@woobling.orgE =head1 COPYRIGHT Copyright (c) 2007 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Devel-ArgNames-0.03/Makefile.PL0000644000076500007650000000044010736727577021065 0ustar nothingmuchnothingmuch00000000000000#!/usr/bin/perl -w use strict; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Devel::ArgNames', VERSION_FROM => 'lib/Devel/ArgNames.pm', INSTALLDIRS => 'site', SIGN => 1, PL_FILES => { }, PREREQ_PM => { PadWalker => 0, 'Test::use::ok' => 0, }, ); Devel-ArgNames-0.03/MANIFEST0000644000076500007650000000037610736732565020245 0ustar nothingmuchnothingmuch00000000000000lib/Devel/ArgNames.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP t/001_basic.t META.yml Module meta-data (added by MakeMaker) SIGNATURE Public-key signature (added by MakeMaker) Devel-ArgNames-0.03/MANIFEST.SKIP0000644000076500007650000000103410736174536021000 0ustar nothingmuchnothingmuch00000000000000# Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \b_darcs\b # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ # Avoid Devel::Cover files. \bcover_db\b ### DEFAULT MANIFEST.SKIP ENDS HERE #### \.DS_Store$ \.sw.$ \.tar\.gz$ ^(\w+-)*(\w+)-\d\.\d+$ Devel-ArgNames-0.03/META.yml0000644000076500007650000000063510736732565020363 0ustar nothingmuchnothingmuch00000000000000--- #YAML:1.0 name: Devel-ArgNames version: 0.03 abstract: ~ license: ~ author: ~ generated_by: ExtUtils::MakeMaker version 6.42 distribution_type: module requires: PadWalker: 0 Test::use::ok: 0 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 Devel-ArgNames-0.03/SIGNATURE0000644000076500007650000000206410736732567020376 0ustar nothingmuchnothingmuch00000000000000This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.55. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 ab8a7e5ffbf2254a99141ffd0cce6d00de8ce312 MANIFEST SHA1 ddb918d4e02cc06f4b9fe77adeca65403f8fdd56 MANIFEST.SKIP SHA1 edddf41d660a50e6acbbf309fd94bb50474437a0 META.yml SHA1 61124877aace6f6df4ec0a1683d830288f12fa93 Makefile.PL SHA1 50068c3298637a6efbfbb4b144809158f07a3b36 lib/Devel/ArgNames.pm SHA1 c5f09fbf33a8344db19ba1cd86777d9f82c08281 t/001_basic.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFHe7V1VCwRwOvSdBgRAh0YAJ9vFkh8Oh6zKWK/dISJjuAa9zi7kwCffnhq ZolyJO7a8iIXtCGtK1+2deU= =vOQy -----END PGP SIGNATURE----- Devel-ArgNames-0.03/t/0000755000076500007650000000000010736732565017351 5ustar nothingmuchnothingmuch00000000000000Devel-ArgNames-0.03/t/001_basic.t0000644000076500007650000000036510736371117021173 0ustar nothingmuchnothingmuch00000000000000#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Devel::ArgNames'; sub foo { arg_names() } my ( $bar, $gorch, @blah ); is_deeply( [ foo($bar, $gorch, $blah[4]) ], [ qw($bar $gorch), undef ], "var names", );