Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use Text::CSV;
- # use strict;
- # use warnings;
- # use diagnostics;
- use utf8;
- binmode(STDOUT, ":utf8");
- my @rows;
- my $field;
- my $outlook;
- # Outlook -> LDAP
- my %mapping = ("Vorname" => "givenName",
- "Nachname" => "sn",
- "Firma" => "o",
- "Straße geschäftlich" => "street",
- "Ort geschäftlich" => "l",
- "Postleitzahl geschäftlich" => "postalCode",
- "Fax geschäftlich" => "facsimileTelephoneNumber",
- "Telefon geschäftlich" => "telephoneNumber",
- "Mobiltelefon" => "mobile",
- "E-Mail-Adresse" => "mail",
- "E-Mail 2: Adresse" => "mail",
- "E-Mail 3: Adresse" => "mail");
- my $csv = Text::CSV->new ( { binary => 1, eol => $/ } ) # should set binary attribute.
- or die "Cannot use CSV: ".Text::CSV->error_diag ();
- open my $fh, "<:encoding(utf8)", "foo.csv" or die "foo.csv: $!";
- $csv->column_names($csv->getline($fh));
- my $hr = $csv->getline_hr_all($fh); # HashRef
- for my $hashref (@$hr) {
- foreach $outlook (keys %mapping) {
- print "Outlook: ".$outlook."\t";
- print "--> ".$mapping{$outlook}."--> ".$hashref->{$mapping}."\n";
- }
- }
- $csv->eof or $csv->error_diag();
- close $fh;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement