perl - Check specific value not in array -
i have array 2 values , need perform operations if input not in array.
i tried like
if ($a ne ('value1' || 'value2') if (($a ne 'value1' ) || ($a ne 'value2' ))
both methods didn't work. can please help?
you use none
function list::moreutils
.
if have array subject line says code this
use list::moreutils 'none'; if ( none { $_ eq $a } @array ) { # stuff }
or if have 2 constants use this
if ( none { $_ eq $a } 'value1', 'value2' ) { # stuff }
but in case prefer see just
if ( $a ne 'value1' , $a ne 'value2' ) { # stuff }
Comments
Post a Comment