my $make_output = sub { "user $_[0] has accessed the system and is $_[1]" }; # apply regex to filter my $output_string = $make_output->( $1, $2 );