in reply to Re^2: help with hash or arrays or hash references
in thread help with hash or arrays or hash references

Here is another way to write that, less typing, fixed to dereference properly ( references quick reference ) , and filtered through perltidy -csc -otr -opr -ce -nibc -i=4

sub Flag { my ( $Subj_id, $proph_prots, $euk_prots, $vir_prots ) = @_; return "Proph", "Phage" if exists $$proph_prots{$Subj_id}; return "Euk", "Euk" if exists $$euk_prots{$Subj_id}; return "Vir", "Phage" if exists $$vir_prots{$Subj_id}; return "Bact", "Bact"; } ## end sub Flag

Replies are listed 'Best First'.
Re^4: help with hash or arrays or hash references
by AWallBuilder (Beadle) on May 09, 2012 at 12:54 UTC
    Thanks for tidying this up. I was not getting just Bact before, so I'm not sure why I didn't have to dereference? I have now changed it to $$ but there is no difference in the output. Sorry I did actually have use strict, but it is at the very beginning of the script which I didn't post.