| CPAN Ratings (Gamma) Devel-ArgNames reviews | |
| Home | Search | About | Login |
RSS | Module Info | Add a review of Devel-ArgNames
4 out of 4 found this review helpful:
I was unaware of this module until I saw the previous review. This module is incredibly useful when you need to debug a long list of arguments. For example:
#!/usr/bin/perl -w
use strict;
use Devel::ArgNames;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
print_args($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
sub print_args {
my @args = arg_names();
my @values = @_;
for my $i (0 .. @args - 1) {
printf "%-10s = %s\n", $args[$i], $values[$i];
}
}
__END__
Prints:
$sec = 25
$min = 43
$hour = 22
$mday = 7
$mon = 4
$year = 108
$wday = 4
$yday = 128
$isdst = 1
John McNamara - 2008-05-08 06:06:33
Was this review helpful to you?
Yes
No
I had to fix some horrible code. It was inserting into the database a huge blob of variables into one big row. It looked like:
bind_to_insert(
$user, $name, $phone, $os, $version, $bitrate, ...
);
36 of these variables were counted between the parentheses. Before refactoring, I wanted to see the values it was inserting on the screen. So I started:
print "user: $user, name: $name..."
Which is no fun.
Luckily I recalled a module Yuval wrote during a lightning talk at a Perl workshop. search.cpan.org showed my exact problem in the 3rd <code> block in the POD.
Replacing bind_to_insert above with the my_print_args from the docs did exactly what I wanted. Delicious.
Note this is not a case of a self praising author. I am on AUTHORS, but wrote not nothingmuch, but nothing at all of it. I think I am on AUTHORS because I sat next to him at the workshop.
Ran Eilam - 2008-04-30 14:08:00
Was this review helpful to you?
Yes
No
|
Perl.org sites
: bugs
| dev
| history
| jobs
| learn
| lists
| use
Site Information and Contacts |
|