$ perl -le " print for grep { my $what = scalar($Q++==0 ..($_ eq q{Q})); warn $what; $what } qw{ a b c Q r s }; " 1 at -e line 1. 2 at -e line 1. 3 at -e line 1. 4E0 at -e line 1. Warning: something's wrong at -e line 1. Warning: something's wrong at -e line 1. a b c Q