in reply to build regular expression from scalar?

You could use a hash of coderefs:

my %actions = ( ADD = \&add, DELETE = \&delete, REMOVE = \&remove, ); # ... if($action =~ /$monitoredActions/) { $_ = uc($action); if(exists $actions{$_}) { $actions{$_}->(); } else { # undefined action. die/warn whatever } } sub add { ... } sub delete { ... } sub remove { ... }

Update: had misunderstood question.