while (1) { print "Enter regex: "; chomp ($regex = <>); print "Enter string: "; chomp ($str = <>); print "Matches!\n" if $str =~ /$regex/o; }