#ok, with a weird example of $1 @result = grep{ print "$1 $_\n" if /^..(A|B)./; /^..(A|B)./}@x; =prints B aaBxyz B ..Bxys A xxAx =cut @result is the same as above # grep {} executes the code within the brackets and passes the input # to @result depending upon the true/false value of the last statement.