($this_mail) # puts the value in a list context so that values captured by the regex are saved in the list (only the first match will be saved as there is only one variable available) = $this_in =~ # apply a regular expression to $this_in /CN=(.*),CN=ExternalContacts/ # capture the bit in brackets gio; #apply globally (g), case insensitively (i) and only compile once (o)