Your code ignores the first two columns, because the columns are numbered from zero.
I don't quite understand your overall goal, but this should help:
#!/usr/bin/perl -w use strict; use Text::CSV::Simple; my $parser = Text::CSV::Simple->new; $parser->want_fields(1, 2, 3, 4); my @data = $parser->read_file(\*DATA); foreach my $line (@data) { if ($line->[0] =~ m/SMTP:/i) { print "here are the parts of the first column:\n"; my @parts_of_first_column = split(';', $line->[0]); foreach my $part (@parts_of_first_column) { print " * $part\n"; } } } __DATA__ "CN=MBX_MANA,OU= Mailboxes,DC=doman,DC=com",SMTP:Manager@domain.com;sm +tp:MBX_MANA@domain.com;FAX:MBX_MANA@domain.com;X400:c=us\;a= \;p=doma +in\;o=Exchange\;s=MANAGER\;,MBX_MANA,/o=Exchange Org/ou=First Adminis +trative Group/cn=Configuration/cn=Servers/cn=SERVER "CN=Guest,CN=Users,DC=domain,DC=com",,Guest,
Which prints out:
here are the parts of the first column: * SMTP:Manager@domain.com * smtp:MBX_MANA@domain.com * FAX:MBX_MANA@domain.com * X400:c=us\ * a= \ * p=domain\ * o=Exchange\ * s=MANAGER\
So Text::CSV::Simple splits up the CSV in a smart way, and then the code splits up the first (remaining) column by semicolons. From there on you should be able to test each part for the stuff you want.
($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print
In reply to Re: Best method of munging CSV data - using Text::CSV::Simple?
by Cody Pendant
in thread Best method of munging CSV data - using Text::CSV::Simple?
by billie_t
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |