in reply to Parsing a csv file from Exchange
while (<DATA>){ chomp; my %rec=(); while ( / ([^:]*) # any amount of non ":"'s -better as ([A-Z0-9]*)? : # followed by a colon ([^%]*) # any amount of non "%"'s %{0,1} # followed by 0 or 1 % characters /xg ){ $rec{$1}=$2; } print $rec{SMTP}, "\n"; # for example } __DATA__ SMTP:makeusbetter@domain.com%X400:c=US;a= ;p=domain ;o=domain;s=makeus +better;%CCMAIL:makeusbetter at domain% CCMAIL:Hunter, Sandy at domain%MS:domainin/domain/sandy%SMTP:sandyh@do +main.com%X400:c=US;a= ;p=domain
The second line of your sample data did not end with an % which I suspect it normally would so I made the % char optional, I think for your actual data you could change the re to /([^:]*):([^%]*)%/g
--
my $chainsaw = 'Perl';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) 2Re: Parsing a csv file from Exchange
by jeffa (Bishop) on May 21, 2002 at 14:30 UTC |