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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -