in reply to About regular expression

Hello

I'll try explaining what this code does. But first: about regular expressions.

Without getting too technical, Regular Expressions are one way of describing a set of words. So, when we say

if ($str =~ /some_re/){ do something ... }
what we're really doing is asking if the string belongs to the set described by the regular expression.

I don't (and can't) explain the whole of perl's regular expressions but I'll explain enough to make you understand the code segment.

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)); } }
Hope this helped

Aziz,,,

Update: Thanks blakem for pointing out the need for escapes for \] in <pre> tags.