my ($first) = /^\s*(\w+)/ or next; if (index $first, "hello") { ... whatever ... } #### my %prefixes = calc_all_unique_prefixes; if (/my ($first) = /^\s*(\w+)/) { if (exists $prefixes{$first}) { do_command $prefixes{$first} } else { print "What?\n"; } }