#!/usr/bin/perl # "ldif2pine.pl" # # script takes a Netscape addressbook LDIF in STDIN # and puts a pine ~/.addressbook format # nicknamenameemailcomment # to STDOUT # usage: # 1) Use Communicator's Address Book "File" -> "Export" to create an LDIF file # 2) ./ldif2pine.pl < netscape.ldif > ~/.addressbook # # caveat: obviously, this wipes out your Pine address book. c'est la vie. while ($line = ) { $line =~ s/\n//; if ( $line =~ /^dn: / ) { # new entry if ( $thisEmail ne "" ) { # we have an address to output print "$thisNick\t$thisName\t$thisEmail"; if ( $thisComment ne "" ) { print "\t\t$thisComment"; } print "\n"; } $thisNick = $thisName = $thisEmail = $thisComment = ""; } if ( $line =~ /^description: (..*?)$/ ) { $thisComment =$1; } elsif ( $line =~ /^xmozillanickname: (..*?)$/ ) { $thisNick = $1; # pine does not allow spaces in nicknames $thisNick =~ s/\s/_/ig; } elsif ( $line =~ /^mail: (..*?)$/ ) { $thisEmail = $1; } elsif ( $line =~ /^cn: (..*?)$/ ) { $thisName = $1; } } exit 0;