my $y = 0; for my $arg (@_){ if ( length $arg == 1 ) { $and .= " AND j$y.LumbolValue = '$arg' " ; # Your elsifs here... } $y++; }