Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How can I get a single record from Google Contacts based on a phone number?

by kennethk (Abbot)
on Mar 27, 2015 at 00:37 UTC ( [id://1121473]=note: print w/replies, xml ) Need Help??


in reply to How can I get a single record from Google Contacts based on a phone number?

What have you tried? What worked? What didn't? What is your experience level with Perl? See How do I post a question effectively?.

Interaction with Google contacts can be accomodated with WWW::Google::Contacts (or this if CPAN search is down).

Checking the number is likely accomplished with mangling the input into a regular expression; perhaps like:

my @terms = $ARGV[0] =~ /(\d{3})(\d{3})(\d{4})/; my $re = qr/^\(?$terms[0]\)?-?$terms[1]-?$terms[2]$/;
or, following your suggested spec
$number =~ s/[^\d:]//g; if (grep $_ eq $ARGV[0], split ':::', $number) { say $number; }
If you are unfamiliar with regular expressions, see perlretut.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: How can I get a single record from Google Contacts based on a phone number?
by Anonymous Monk on Mar 27, 2015 at 01:13 UTC

    I haven't tried anything so far because I literally had no idea where to start. I've been reading the page on WWW::Google::Contacts and it looks like this may be the tool I need. My only mental hurdle will be figuring out how to use it effectively. Also, the REGEX is a huge help, I was never any good at those.

    As far as my experience level, in many respects I'm a rank beginner. I had some very brief exposure to Perl several years ago but I am old enough (don't ask, but I'm old enough to remember when a pe(a)rl was something dropped into a bottle of Prell shampoo in TV commercials) where if I haven't done something in the last week or two, the memory of how to do it fades quickly. I wrote a few very short programs back then to do small tasks and I am actually still using a couple of them, and this is another of those small tasks I was hoping Perl might be well suited for. So thanks for giving me a push in the right direction; it may take me a few days to figure it all out but at least now I have something to work with!

Re^2: How can I get a single record from Google Contacts based on a phone number?
by Anonymous Monk on Mar 27, 2015 at 08:12 UTC

    As it turns out, WWW::Google::Contacts will not install. After installing MANY other modules (an unbelievable number), it failed because it could not install some dependencies (I forget which ones now). So, that's not going to work, I guess, and there is no way I would try installing it again because of the HUGE number of other modules it brought in. I had to revert my system back to a snapshot I had made earlier just to get rid of the mess.

    Perl never used to be like that; I remember when installing modules that sometimes it would bring in two or three others but that thing literally installed modules for over an hour, asking me EVERY SINGLE TIME it found yet another dependency it thought it needed to install. Absolutely ridiculous! Thanks for your help anyway, I'm not faulting you for suggesting it, in fact I'm not sure who's at fault but I just lost any desire I had to mess with Perl again.

      there is no way I would try installing it again because of the HUGE number of other modules it brought in.

      If this (the total number of dependencies) is important to you, then you might find it useful in future cases to look at deps.cpantesters.org where you can see the full dependency tree of any module. You can then judge whether the installation would be worth the effort.

      asking me EVERY SINGLE TIME it found yet another dependency it thought it needed to install. Absolutely ridiculous!

      Of course whichever utility you have used to perform the installation will have an option to automatically install all the dependencies without asking this question every time. Since you have not said which utility you used, I cannot advise you further. If you consult the documentation (even the usage message) for that utility it should be clear enough which option to use.

      It is helpful to say which one would not install and take a look at why. Sometimes it is a matter of getting a non-Perl rerequisite (such as the GCC). But usually this can be addressed or we can help you work on getting it fixed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1121473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-16 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found