You ever have days where where you stare at code that has absolutely nothing wrong with it and you try to figure out why it's not working?
eval { "use $factory_class" };
I blew about five minutes trying to figure that out. What's worse, it was throwing a warning, so I made that go away.
no warnings 'void'; eval { "use $factory_class" };
Yeah, real impressive coding there. Were it not for my test suite, that would have passed silently into production.
I actually make this mistake about once a week. For all the complaining I do about functions doing I/O on their own, I wish this one did.%hash =...;
Dumper( \%hash );
Re:Join the club, get the jacket
Ovid on 2005-11-16T01:20:51
use Data::Dumper::Simple autowarn => 1;
my %hash = (
foo => 1,
bar => 'baz',
);
Dumper(%hash);
__END__
%hash = (
'bar' => 'baz',
'foo' => 1
);Of course, that just led me to a bug in the docs which incorrectly identifies the attribute as autodump. I need to go fix that.
Or, if you're like me and you set up editor bindings to spit out boilerplate quickly, then you won't mind this interface:
use Data::Dumper::Simple
as => 'dump',
autowarn => 1;
my %hash = (
foo => 1,
bar => 'baz',
);
dump %hash;
I just wasted days on one where MySQL told me I had a syntax error in my query, which I clearly didn’t. The problem was in $sth->execute( map $cgi->param( $_ ), @paramname );
– can you spot it?
Re:
Ovid on 2005-11-16T08:25:13
Erm, not quite sure. Could it be a list context issue where you have list elements dropping out or extra elements getting inserted?
Re:
Aristotle on 2005-11-16T10:26:06
Exactly. I had to bung an extra
scalar
in there, à la$sth->execute( map scalar $cgi->param( $_ ), @paramname );I failed to see the problem for days even though I had done this correctly in every other instance of this snippet.