November 2011 Archives

Extract Mail Adresses from CSV

What do you think about the code below?
I have a file containing information about people, where the fifth element of the tab separated line contains the mail address.
Each mail address appears multiple times, I need to print them unique.

my %mails;
open my $csv, '', 'my.csv' or die $!;
while ($csv>){
    my  $mail = ( split(/\t/) )[4]; 
    $mails{$mail} = 1
}
say foreach sort keys %mails;

(and how do I indent code on blogs.perl.org?)
thx @Aristotle

About :m)

user-pic I blog about Perl.