Hello,
is there a way to use something like brackets for more complex IF commands? I know of "and", "or", but how can those be combined for complex commands? For example:
-if "$var1 eq '1' and $var2 eq '2' or $var3 eq '3'"
With brackets this could be meant as
-if "$var1 eq '1' and ($var2 eq '2' or $var3 eq '3')"
or
-if "($var1 eq '1' and $var2 eq '2') or $var3 eq '3'"
Your examples show the correct way to set precedence. Exiftool is written in Perl, so you can look at any Perl tutorial on its operators.
From the perlop man page:
Perl operators have the following associativity and precedence, listed
from highest precedence to lowest. Operators borrowed from C keep the
same precedence relationship with each other, even where C's precedence
is slightly screwy. (This makes learning Perl easier for C folks.)
With very few exceptions, these all operate on scalar values only, not
array values.
left terms and list operators (leftward)
left ->
nonassoc ++ --
right **
right ! ~ \ and unary + and -
left =~ !~
left * / % x
left + - .
left << >>
nonassoc named unary operators
nonassoc < > <= >= lt gt le ge
nonassoc == != <=> eq ne cmp ~~
left &
left | ^
left &&
left || //
nonassoc .. ...
right ?:
right = += -= *= etc. goto last next redo dump
left , =>
nonassoc list operators (rightward)
right not
left and
left or xor
- Phil