in reply to is this right ?

Or you could use the five values as keys in %hash, and simply test
if ( defined( $hash{ $fields[6] } ) { # do something }