in reply to CSV File Question

use strict; while (<DATA>) { chomp; if (/CN=\w+/) { $_ =~ s/^(.+?"CN=.+?),.+$/$1"/; print "$_\n"; } } __DATA__ DHCP Administrators,2,"Enterprise Admins,Users,DC=INTERNETNET,DC=com Domain Admins,Users,DC=INTERNETNETCOM,DC=com",, DnsAdmins,2,"Enterprise Admins,Users,DC=INTERNETNET,DC=com Domain Admins,Users,DC=INTERNETCOM,DC=com",, AS400 Query Database,2,"CN=Joe Car,OU=Systems/Operations,OU=MIS,OU=Use +r Accounts,DC=INTERNETNET,DC=com Ricrad Tallar,OU=Systems/Operations,OU=MIS,OU=User Accounts,DC=INTERNE +TNETCOM,DC=com",, Deptpar Access,8,"John Class,OU=Marketing,OU=User Accounts,DC=INTERNET +NET,DC=com Judy Lipa,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com George Grey,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Artur More,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Raimun Sirilo,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com Amilcar Ove,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Daniel Santos,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com Paula Corte,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com" Human_Resources,3,"CN=Katarine Gilly,OU=Executive,OU=User Accounts,DC= +INTERNETNET,DC=com Chris Head,OU=Human Resources,OU=Finance & Administration,OU=User Acco +unts,DC=INTERNETNET,DC=com Susany Cadru,OU=Human Resources,OU=Finance & Administration,OU=User Ac +counts,DC=INTERNETNET,DC=com"

Replies are listed 'Best First'.
Re^2: CSV File Question
by Anonymous Monk on Jan 13, 2005 at 04:15 UTC
    Almost there I just need to rid of the rest of the stuff inside the quotes that isn't CN
      ..I just need to rid of the rest of the stuff inside the quotes that isn't CN

      As requested, the above returns..
      AS400 Query Database,2,"CN=Joe Car"
      Human_Resources,3,"CN=Katarine Gilly"

      What do you need it to return?
        If finds any CN from where the first quote starts to the next closing quote.
        Like in this first paragraph the end result should be like:

        DHCP Administrators,2,"CN=Daniel Santos,CN=Paula Corte"

        The same for the others


        Thanks

        Here some data example;
        DHCP Administrators,2,"Enterprise Admins,Users,DC=INTERNETNET,DC=com Domain Admins,Users,DC=INTERNETNETCOM,DC=com,, CN=Daniel Santos,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com CN=Paula Corte,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com" DnsAdmins,2,"Enterprise Admins,Users,DC=INTERNETNET,DC=com Domain Admins,Users,DC=INTERNETCOM,DC=com",, AS400 Query Database,2,"CN=Joe Car,OU=Systems/Operations,OU=MIS,OU=Use +r Accounts,DC=INTERNETNET,DC=com Ricrad Tallar,OU=Systems/Operations,OU=MIS,OU=User Accounts,DC=INTERNE +TNETCOM,DC=com",, Deptpar Access,8,"CN=John Class,OU=Marketing,OU=User Accounts,DC=INTER +NETNET,DC=com Judy Lipa,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com CN=George Grey,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Artur More,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com CN=Raimun Sirilo,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com CN=Amilcar Ove,OU=Marketing,OU=User Accounts,DC=INTERNETNET,DC=com Daniel Santos,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com Paula Corte,OU=Executive,OU=User Accounts,DC=INTERNETNET,DC=com" Human_Resources,3,"CN=Katarine Gilly,OU=Executive,OU=User Accounts,DC= +INTERNETNET,DC=com CN=Chris Head,OU=Human Resources,OU=Finance & Administration,OU=User A +ccounts,DC=INTERNETNET,DC=com Susany Cadru,OU=Human Resources,OU=Finance & Administration,OU=User Ac +counts,DC=INTERNETNET,DC=com" =comment