in reply to Best method of munging CSV data - using Text::CSV::Simple?
Output is exactly what I wanted. Thanks for all your help, guys!#! /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"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best method of munging CSV data - using Text::CSV::Simple?
by Scott7477 (Chaplain) on Feb 06, 2007 at 00:11 UTC |