in reply to How do I store all matches from a single line?
I don't like that though -- I'll qualify that -- hard-coding the indices seems like a bad idea, eg. if the data were to change to 4 sets of name/email on a line then this breaks. It's only a quick fix to get it working again but I still don't like it - call me fussy. I suggest the following (again, doesn't offer dodgy-data handling -- but will take as many on a line as are provided)...# array my @emails = (); while (<DATA>) { push @emails, (split /[<>]/)[1,3,5]; }
The hash-way means you don't lose the name info although, since names are not unique and email addresses are, you should maybe use the email as the key and the name as the value! I'll leave that for you to work out. Hope this helps, larryk# hash undef $/; my %emails = split /[<>\n]+/, <DATA>;
"Argument is futile - you will be ignorralated!"
|
|---|