in reply to How can I create a procedure
i think what you're after is a kind of perlish "ON $VAR GOTO" kind of thing (from BASIC language). build a hash of the text constants you're testing for as keys with values being references to anonymous subroutines. then it's a case of dereferencing the hash with $_ to execute the code. this will work as long as your current matching =~ is realy meant to be an eq operator. if it is meant to scan whole lines for the pattern than my suggestion will not work. good luck.