How to search for string in an array using grep? : I have an array which contains some file names ,I'm trying to grep the particular file name which matches the string ..

    @arr=qw(INS.INPUT01.S7779902 INS.INPUT01.S7779903 INS.INPUT01.S7779904);
    $str = "7779902";
    
    if (grep{$_=~ /$str/} @arr){
    print $_;
    }