if ($str =~ /some_re/){ do something ... } #### foreach (qw/one one.five two two.one two.ten two.ten.12 three three.nine four five/){ print "$_\n"; if($_ =~ /\./){ # if the word has a dot ".". # Keep everything after the last "." in the string my ($label) = /\.([^\.]*)$/; # a dot, followed by zero # or more letters that are # not dots, attached to the # end of the string. # return those letters # since they're between # brackets. $tree->add($_, -text => $label , # add the label to $tree -image => $mw->Getimage(folder)); } }