CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Advanced:
multi file join by line



Jul 24, 2007, 11:32 AM

Post #1 of 2 (696 views)
multi file join by line Can't Post

I have a script that will join multiple files line by line into a single file (e.g., the first line of every file is inserted underneath one another starting with the dn:). Each file has to have the same number of lines.

This works great, however, many of the files I'm using are static for each LDAP record I'm creating; so how do I join the unique lines with the static lines to create unique individual records.

For example: file1 contains the dn, file2 the uid, file3 the email, file4 givenName.

File5-10 contain the same objectclass attributes: Top, Person, inetOrgPerson, etc.

If I have 1000 users accounts to create, I have to dummy up 5 files with 1000 entries of each objectClass.

Isn't there a way to build a record for a user containing the lines from the unique file attributes with a list of static attributes getting a record like this:

dn: cn=RFrancis,ou=ABC,ou=ABC External Users,ou=NA,o=ABC
objectClass: Top
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: Person
objectClass: ndsLoginProperties
manager: LFrancis
uid: RFrancis
givenName: Richard
sn: Francis

Thank you.


Jul 24, 2007, 11:55 AM

Post #2 of 2 (695 views)
Re: [rfransix] multi file join by line [In reply to] Can't Post

Here's the code I have multiple files. If I make one of the files contain all the objectclasses, it breaks.

$newline = "\n";

open(FILE1, $ARGV[0]);
open(FILE2, $ARGV[1]);
open(FILE3, $ARGV[2]);
open(FILE4, $ARGV[3]);
open(FILE5, $ARGV[4]);
open(FILE6, $ARGV[5]);
open(FILE7, $ARGV[6]);
open(FILE8, $ARGV[7]);
open(FILE9, $ARGV[8]);
open(FILE10, $ARGV[9]);
open(FILE11, $ARGV[10]);
open(FILE12, $ARGV[11]);

while ($line = <FILE1>) {
$line =~ s/\n//;
print STDOUT $line . $newline . <FILE2> . <FILE3> . <FILE4> . <FILE5> . <FILE6> . <FILE7> . <FILE8> . <FILE
9> . <FILE10> . <FILE11> . <FILE12>;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives