in reply to Help Needed

Is it always dn: ou=CA, or what can be in between dn and CA? Assuming that you read the file line by line, something like

my $value=undef; open(FILE,'<',$filename) or die "$filename: $!"; while(<FILE>) { if(/\bdn:\s*ou=(\w+)/) { $value=$1; last; } }
could do.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^2: Help Needed
by scott_apc (Initiate) on Feb 03, 2009 at 12:28 UTC
    Hi, RE: My file contains several occurence of "dn:" and I am only concerned with the first occurence and it will not be always dn: ou=CA, the value CA might change. Regards, Scott

      Of course your value of CA will change, otherwise you wouldn't have to extract it! But what will be the general pattern between dn and CA? Is it always ': ou=' or something different?

      But in any case, with the solution I posted, I think you now know how to do it...

      -- 
      Ronald Fischer <ynnor@mm.st>
        Thanks, I am able to get it, but I dont get the results where I have "CA-ABC", instaed of "CA",