Subject: | help detecting problems |
Date: | Thu, 28 Aug 2014 18:55:47 +0000 |
To: | "bug-Algorithm-Diff [...] rt.cpan.org" <bug-Algorithm-Diff [...] rt.cpan.org> |
From: | Martin Smoot <MSmoot [...] ejcaimen.com> |
I was having trouble with adding my own compare routine (until I saw a bug report from 2012 documenting how to do the call). it turns out that I was doing the right call but had a typo that caused it to not work.
as a test I added this code to my copy of Diff.pm to detect the problem that I had - something like this may be very helpful for future developers who make trivial mistakes:
sub new
{
my( $us, $seq1, $seq2, $opts ) = @_;
my @args;
#
# begin suggested change
#
if(defined $opts)
{
my $paramtype=ref $opts;
$paramtype="Unknown" if !defined $paramtype || $paramtype eq "";
if ($paramtype ne "HASH")
{
print STDERR "Unexpected parameter type for options: $paramtype\n";
}
else
{
my $found_valid_options_in_hash=0;
foreach (sort keys %$opts)
{
if($_ eq "keyGen" || $_ eq "keyGenArgs")
{
$found_valid_options_in_hash=1;
}
else
{
print STDERR "Unknown hash item found in options: $_\n";
}
}
print STDERR "no keyGen or keyGenArgs entry found in options\n" if $found_valid_options_in_hash==0;
}
}
#
# end suggested change
#
for( $opts->{keyGen} ) {
push @args, $_ if $_;
}
for( $opts->{keyGenArgs} ) {
push @args, @$_ if $_;
}
Show quoted text
________________________________
This message is private and confidential. If you have received this message in error, please notify us by replying to this email and then delete it from your system. Thank you for your cooperation. EJ Caimen, Inc.