Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I just thought I'd post the finished work of art:
#! /usr/bin/perl #parsing Exchange output file to create address aliases use strict; use warnings; my($infile) = ("C:\\recipient.txt"); my($outfile) = ("C:\\outfile.txt"); use Text::CSV::Simple; open(OUTPUT, ">$outfile") or die "Can't open $outfile : $!"; my $parser = Text::CSV::Simple->new; $parser->want_fields(1, 2, 3); my @data = $parser->read_file($infile); foreach my $line (@data) { # process only accounts that contain SMTP addesses + if ($line->[0] =~ m/SMTP:/i) { my $user = $line->[1]; my $server = substr(($line->[2]), -6); #split up the line that contains all the email addresses my @smtp = split(';', $line->[0]); foreach my $part (@smtp) { # do not process anything that is not an SMTP address # (exclude fax & X400) if ($part =~ m/SMTP:/i) { $part = substr($part, 5); print OUTPUT ("$user\@$server \t $part\n"); } } } } # CSVDE command used on domain controller to # generate recipient information for users in domain # Dumps the user name, all proxy addresses # and the home mailbox server - it WON'T exclude the DN. # csvde -m -n -g -f "C:\recipient.txt" -r "(|(&(objectClass=user)(obje +ctCategory=person))(objectClass=groupOfNames)(objectClass=msExchDynam +icDistributionList))" -o "distinguishedName, DN" -L "name,proxyAddres +ses,msExchHomeServerName"
Output is exactly what I wanted. Thanks for all your help, guys!

In reply to Re: Best method of munging CSV data - using Text::CSV::Simple? by billie_t
in thread Best method of munging CSV data - using Text::CSV::Simple? by billie_t

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2021-09-17 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?