Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Theory (10)

Theory
  (email not shown publicly)
http://www.justatheory.com/
AOL IM: dwTheory (Add Buddy, Send Message)
Yahoo! ID: dew7e (Add User, Send Message)
Jabber: Theory@jabber.org

Perl, PostgreSQL hacker; US politics junkie; Webapp developer; Portvangelist; profane iconoclast.

On CPAN see: DWHEELER [cpan.org].

Journal of Theory (10)

Thursday May 20, 2004
08:52 PM

Internationalizing Numbers in Address Book

[ #18860 ]

Anyone got a recipe to go through all of the phone nubmers in the Panther Address Book and add "+1 " to any numbers that don't have a + International code? Mac::Carbon, AppleScript, XML::Parser, or any approach would be welcome.

Thanks!

David

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • use Mac::Glue;
     
    my $ab = new Mac::Glue 'Address Book';
     
    my $people = $ab->obj('people');
    for my $person ($people->get) {
        for my $phone ($person->prop('phone')->get) {
            my $value  = $phone->prop('value');
            my $number = $value->get;
            if ($number =~ /whatever/) {
                $number = "whatever";
                $value->set(to =

    • pudge++

      This did the trick for me. Thanks!

      use Mac::Glue;

      # sudo gluemac /Applications/Address\ Book.app

      my $ab = new Mac::Glue 'Address Book';

      my $people = $ab->obj('people');
      for my $person ($people->get) {
          for my $phone ($person->prop('phone')->get) {
              my $value  = $phone->prop('value');
              my $number = $value->get;
              next if $number =~ /^41-/ || $number =~ /^0/;
              next

      • Great, glad it worked. I saw something about uninitialized values in IRC, did you figure that one out?
        • No, I just removed the -w from the shebang line. It was a one-off, and so not worth the effort to debug. Must've been a problem with the data in my address book...