ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: jvradelis on April 14, 2013, 01:52:10 PM

Title: Error in IsEqual subroutine in exiftool script
Post by: jvradelis on April 14, 2013, 01:52:10 PM
System type:  Mac
Exiftool version:  9.26
Command line:  /usr/bin/exiftool -l -X [filename].DNG
Error message:  Can't use string ("[filename].DNG") as an ARRAY ref while "strict refs" in use at /usr/bin/exiftool line 2814.

I think there may be a bad dereference in the IsEqual subroutine at line 2814 of exiftool.  I get the error message above when I run it on a DNG file, and Rob Cole's ExifMeta plugin fails to write the exifdata in Lightroom.  However, if I change line 2814 from

    return 0 if $$_[0][$i] ne $$_[1][$i];

to:

    return 0 if ${$_[0]}[$i] ne ${$_[1]}[$i];

the error message goes away, and exiftool appears to work as intended, and the plugin successfully reads and writes the data.

I don't think the original line is doing what you intend.  It's been quite a few years since I did any heavy lifting in Perl, but I think what's happening is that the $$ bind closely to _ (more closely than []) and Perl thinks you're trying to dereference _ as an array ref.  But _ isn't an array ref, it's an array.  If you add the braces as in the changed line, it causes _[0] and _[1] to be dereferenced as array refs (which they are at that point).

Don't know why I only seem to see this with DNG files, but it may be that DNGs have the filename as data while NEFs and JPGs do not.  Haven't been able to work that all the way through.




Title: Re: Error in IsEqual subroutine in exiftool script
Post by: Phil Harvey on April 14, 2013, 03:14:38 PM
Thanks for this report!

You're right.  Darn.  This bug was introduced in 9.25, which was a production version too.

It should have been:

    return 0 if $_[0][$i] ne $_[1][$i];

This will be fixed in 9.27.

Your code also works.  I'll have to think about why.

- Phil

Edit: Version 9.27 is now available.  Also, I'm back at work now and could check my "Programming Perl" reference book, and it says that "$LoL[1][2] is just a convenient way to write ${$LoL[1]}[2]".
Title: Re: Error in IsEqual subroutine in exiftool script
Post by: jvradelis on April 15, 2013, 10:45:03 AM
All fixed in 9.27.  Thanks, Phil.