if (scalar(grep/HRC/, $att) > 0) { $var = 1; } elsif (scalar(grep/LRC/, $att) > 0) { $var = 2; } else { $var = 0; }