sub regex { my $in = shift; # Assign something to $ret in a code assertion my $function = (caller 0)[3]; no strict 'refs'; $$function = ''; $in =~ m/^(a)(?{ $$function = 1})/; return $$function; } while() { print regex($_) . "."; } __DATA__ a b a abcd bcda