I have my code like this:
if ( $var eq \"str1\" || $var eq \"str2\" || $var eq \"str3\" ) { ... }
Is there anyways to optimize this. I want
For a list of fixed strings, convert your list to a hash. This is especially useful if you are going to check against your list several times, and if your list gets larger.
%on_my_list = map {; $_ => 1 } 'str1', 'str2', 'str3', ...; if ($on_my_list{$var}) { ... }