Hi, i need help for parsing user data exported from Active Directory using csvde tool. This tool generate a csv export file where one column proxyAddresses contains multiple values like this:

smtp:Martin.Mueller@cde.org;x500:/O=WGR/OU=DE-ABCSOMMERLAND-01/cn=Reci +pients/cn=J63042;X500:/o=CKAG/ou=FIL/cn=Recipients/cn=J63042;X400:c=D +E;a= ;p=CKAG;o=FIL;s=Mueller;g=Martin;;SMTP:Martin.Mueller@acme.net;s +mtp:J63042@acme.net;MRS:J63042@FIL.ckag.mrs

This value represent different addresses of the user used by Exchange server for different connections (e.g. smtp). Every single address

I need to separate this values. The problem i have is the x400 address which consists of multiple parts which are also divided by an ";"!

I tried to split using split ';' $field which works fine but also splits the X400 address to it's parts which is correct. I also tried to split using a beginning sequence split/(MRS|mrs|smtp|SMTP|[xX][45]00):/ $field to get a list of all services and their values but this gives me a list starting with an empty value followed by a first service name followed by a first service address...

Could you explain please how to get list of elements which contains one complete entry per line e.g.

a hash with with service and address would be fine too but there is a possibility to have multiple addresses per service!

Here a bit of code which maybe shows the problem more clear. Thank you in advance!
#use Modern::Perl; use strict; user warnings; use Data::Dumper; my @fields = ( 'smtp:Martin.Mueller@cde.org;x500:/O=WGR/OU=DE-ABCSOMM +ERLAND-01/cn=Recipients/cn=J63042;X500:/o=CKAG/ou=FIL/cn=Recipients/c +n=J63042;X400:c=DE;a= ;p=CKAG;o=FIL;s=Mueller;g=Martin;;SMTP:Martin.M +ueller@acme.net;smtp:J63042@acme.net;MRS:J63042@FIL.ckag.mrs', 'smtp:Olga.Muster@cde.org;x500:/O=WGR/OU=DE-ABCSOMMERL +AND-01/cn=Recipients/cn=J68392;X500:/o=CKAG/ou=FIL/cn=Recipients/cn=J +68392;X400:c=DE;a= ;p=CKAG;o=FIL;s=Muster;g=Olga;;SMTP:Olga.Muster@ac +me.net;smtp:J68392@acme.net;MRS:J68392@FIL.CKAG.mrs', 'smtp:j12345@acme.net;smtp:Alex.Kaiser@cde.org;MRS:j12 +345@FIL.ckag.mrs;SMTP:Alex.Kaiser@acme.net;X400:c=DE;a= ;p=CKAG;o=FIL +;s=Kaiser;g=Alex;', 'smtp:Joseph.Mann@cde.org;x500:/O=WGR/OU=DE-ABCSOMMERL +AND-01/cn=Recipients/cn=J68355;X500:/o=CKAG/ou=FIL/cn=Recipients/cn=J +68355;X400:c=DE;a= ;p=CKAG;o=FIL;s=Mann;g=Joseph;;SMTP:Joseph.Mann@ac +me.net;smtp:J68355@acme.net;MRS:J68355@FIL.CKAG.mrs', ); foreach my $value (@fields) { print "$value\n"; print Dumper(split (';', $value)); print "\n"; } foreach my $value (@fields) { print "$value\n"; print Dumper(split (/(MRS|mrs|smtp|SMTP|[xX][45]00):/, $value)); print "\n"; }

In reply to Parse proxyAddresses field of csvde export by wwe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.