Skip Menu |

This queue is for tickets about the WWW-Contact CPAN distribution.

Report information
The Basics
Id: 41576
Status: rejected
Priority: 0/
Queue: WWW-Contact

People
Owner: fayland [...] cpan.org
Requestors: gms8994 [...] dp.cx
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: WWW::Contact::Yahoo enhancement
Patch to allow returning all results from Yahoo contact information.
Subject: Yahoo.pm.patch
--- Yahoo.pm.bak 2008-12-09 16:34:01.000000000 -0500 +++ Yahoo.pm 2008-12-09 17:25:13.000000000 -0500 @@ -1,6 +1,7 @@ package WWW::Contact::Yahoo; use Moose; +use Text::CSV; extends 'WWW::Contact::Base'; our $VERSION = '0.16'; @@ -44,19 +45,23 @@ ); $content = $ua->content(); - my $i; - while ( $content - =~ /^\"(.*?)\"\,\".*?\"\,\"(.*?)\"\,\".*?\"\,\"(.*?)\"\,\".*?\"\,\".*?\"\,\"(.*?)\"/mg - ) { - $i++; - next if ( $i == 1 ); # skip the first line. - next unless ( $3 or $4 ); - my $email = $3 || $4 . '@yahoo.com'; - my $name = ( $1 or $2 ) ? "$1 $2" : $4; - push @contacts, { - name => $name, - email => $email, - };; + + my ($i, @header_columns, @rows); + my $header_row = (split(/\n/, $content))[0]; + my $csv = Text::CSV->new(); + $csv->parse($header_row."\n"); + if (!defined($csv->fields())) { die $csv->error_diag(); } + @header_columns = $csv->fields(); + my %columns = map { $header_columns[$_] => $_; } 0..$#header_columns; + @rows = map { $_ .= "\n"; } split(/\n/, $content); + shift(@rows); + foreach my $row (@rows) { + $csv->parse($row); + my @values = $csv->fields(); + + my %contact_info = map { $_ => $values[$columns{$_}] } keys(%columns); + + push @contacts, \%contact_info; } return wantarray ? @contacts : \@contacts;
在 2008-12-09 17:29:07 星期二 时,gms8994 写到: Show quoted text
> Patch to allow returning all results from Yahoo contact information.
well, there is a problem. see I'm a Chinese Yahoo! Mail user, and the CVS would return something like "First","Middle","Last","昵称","电邮", which breaks a lot. and another thing in the code. the Email field in Yahoo CVS is Yahoo! ID sometimes. and we can't figure out the postfix as @yahoo.com or @yahoo.com.hk or others. to be simple, the old code just put @yahoo.com as postfix. I hope my explanation helps. Thanks.