($random_char) = "string" =~ /your_magic_here/s; #### "string" =~ /(?=(?>^.*(?{$n=int rand$+[0]})))(??{".{$n}"})(.)/s