Tuna has asked for the wisdom of the Perl Monks concerning the following question:
This will print, for instance:#!/usr/bin/perl -w use strict; use Text::CSV; my $file = "/home/trix/Desktop/thisone.CSV"; my ($line, $key1, $key2, $test, $key3, @field, $members, $owner); my $count = 0; my $csv = Text::CSV->new(); open IN, "$file" or die "Can't open $file: $!\n"; while ($line = <IN> ){ chomp $line; $csv->parse($line) ; @field = $csv->fields; $key1 = $field[1]; $key2 = $field[2]; $key3 = $field[3]; ++$count; if ($key1 =~ s/^\\\~//) { print "List: $key1\n"; } if ($key2 =~ /\/o\=NETC\/ou\=(.*)\/cn\=Recipients\/cn\=(.*)/g) { $owner = $2; } else { $owner = "ssesar"; } print "Owner: $owner\n"; ($members) = ($key3 =~ /\=(.*)\%/g); ^^^^^^^^^^^^^^^^ # problematic code print "Members: $members\n\n"; print "############################################\n\n"; } print "Boston: $count lists\n
My question is, how can I extract only the member's names from the string of data after Members:?############################################ List: Prod Dev SP Owner: NONE Members: Boston/cn=Recipients/cn=jdye%/ou=San Francisco/cn=Recipients +/cn=onisbett%/ou=Boston/cn=Recipients/cn=acorneau%/ou=Boston/cn=Recip +ients/cn=kfleming%/ou=Boston/cn=Recipients/cn=amiller%/ou=Boston/cn=R +ecipients/cn=rcrow%/ou=Boston/cn=Recipients/cn=tgoshco%/ou=San Franci +sco/cn=Recipients/cn=ldixon ############################################ List: Prod Dev IT+CR+ME Owner: NONE Members: San Francisco/cn=Recipients/cn=medelstein%/ou=Boston/cn=Reci +pients/cn=thodes%/ou=San Francisco/cn=Recipients/cn=gdistasi%/ou=Bost +on/cn=Recipients/cn=staylor%/ou=Boston/cn=Recipients/cn=drico%/ou=Bos +ton/cn=Recipients/cn=kkarrman%/ou=Boston/cn=Recipients/cn=tgoshco%/ou +=San Francisco/cn=Recipients/cn=rscaife ############################################
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching every instance of text between two characters
by bikeNomad (Priest) on Jun 24, 2001 at 03:08 UTC | |
|
Re: Matching every instance of text between two characters
by toma (Vicar) on Jun 24, 2001 at 06:23 UTC |