# ... up to this point, # you must have read 1 line from the file ... # and (for sake of example) the email field saved in into $email_field variable. my @emails; while ($email_field =~ m/SMTP:([^\%]+)\%/g) { # validate matched email first... (as per UPDATE) push @emails, $1; # add email address to the list } # @emails array now contains all SMTP email addresses # found in the field.