Facebook phone numbers onto my phone!

So, I got a new phone recently.  Not wanting to awkwardly type numbers in, or worse yet, ask people, I wrote a little script to convert what I copied from the facebook mobile phonebook to a nice CSV file.  I then used BitPim and bluetooth magic to transfer the numbers directly to my phone!  Viola, hundreds of phone numbers on my phone in a few minutes.  The perl script to make the conversion is below…


#for file slurping
undef $/;
$line = <INPUT>;

#get ride of empty lines
$line =~ s/\n\n/\n/g;

#make the numbers pretty
$line =~ s/([0-9]){0,1}[\-\.\)\( ]([0-9])/$1$2/g;
$line =~ s/([0-9]){0,1}[\-\.\)\( ]([0-9])/$1$2/g;

#we only want mobile numbers (ending in M)
$line =~ s/([0-9])M\n/$1\n/g;
$line =~ s/\n([0-9])+[A-Za-z]\n/\n/g;

#get ride of the letter headings
$line =~ s/\n[A-Z]\n/\n/g;
$line =~ s/\n[A-Z]\n/\n/g;
$line =~ s/\n[A-Z]\n/\n/g;

#Comma delimitation!

$line =~ s/\n(.+[a-zA-Z])\n([0-9]{1,})/\n$1,$2/g;
$line =~ s/\n(.+[a-zA-Z].+)\n([0-9]{1,})/\n$1,$2/g;

print “$line”;

Sofa is waiting for you

Posting your comment, please wait!