#!/usr/bin/perl $regex = "(?{print \"Hey!\";}"; $string = "some word"; $string =~ /some($regex)/;