ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: StarGeek on July 10, 2016, 05:40:09 PM

Title: error text change with 10.22, printformat, and user defined tags
Post by: StarGeek on July 10, 2016, 05:40:09 PM
I started using 10.22 and encountered a change to the error text when using -p and user-defined tags that return undefined.

Under 10.13, I would get the error text
Warning: [Minor] Tag 'UserDefinedTag' not defined - FileName

Under 10.22, the error text is:
Warning: ValueConv UserDefinedTag: Can't use 'defined(@array)' (Maybe you should just omit the defined()?) - FileName

-m suppresses the error under 10.13, but not under 10.22.
Title: Re: error text change with 10.22, printformat, and user defined tags
Post by: Phil Harvey on July 10, 2016, 08:52:37 PM
OK, thanks.  I'll look into this.

- Phil
Title: Re: error text change with 10.22, printformat, and user defined tags
Post by: Phil Harvey on July 11, 2016, 07:48:29 AM
OK.  This is due to a difference in the version of Perl.  It seems that you can no longer check to see if an array is defined.  The same thing happened for hashes in an earlier version of Perl.  But you likely don't want to check "defined(@array)" anyway.  To see if the array is empty, simply test "@array" to see if it is true (as the warning suggests).

- Phil
Title: Re: error text change with 10.22, printformat, and user defined tags
Post by: StarGeek on July 11, 2016, 11:11:11 AM
Quote from: Phil Harvey on July 11, 2016, 07:48:29 AM
But you likely don't want to check "defined(@array)" anyway. 

I don't believe I was checking if an array was defined.  Here's a sample of a tag that throws the error.
UniqueKeywords => {
Require => 'Keywords',
ValueConv => q{
my @list = ref $val ? @$val : ($val);
my %seen;
my @new = grep{ ! $seen{ $_ }++ } @list;
return( join('',@list) ne join('',@new)  ? \@new : undef);
},         
},


And commands:
c:\>exiftool -keywords X:\!temp\Test5.jpg
Keywords                        : Keyword 1, Keyword 2, keyword 6

c:\>exiftool -p "$UniqueKeywords" X:\!temp\Test5.jpg
Warning: ValueConv UniqueKeys: Can't use 'defined(@array)' (Maybe you should just omit the defined()?) - X:/!temp/Test5.jpg

Title: Re: error text change with 10.22, printformat, and user defined tags
Post by: Phil Harvey on July 11, 2016, 11:24:41 AM
The ValueConv warning is for "UniqueKeys", but you have shown me the definition for "UniqueKeywords".  Is this a transcription error, or is there another definition causing this warning?

- Phil
Title: Re: error text change with 10.22, printformat, and user defined tags
Post by: StarGeek on July 11, 2016, 12:00:07 PM
D'oh, I did it again.  You are correct.  UniqueKeys is separate.
Title: Re: error text change with 10.22, printformat, and user defined tags
Post by: Phil Harvey on July 11, 2016, 12:08:06 PM
:)