This is how I would do it. To every one else, please feel free to critique my perl programming skills. I'm a Mainframe Assembler programmer and still learning perl. Any critique will just help to improve my skills. use strict; > use Data::Dumper; > my $inpf = 'student.txt'; > open (DATA, $inpf) or die "Can't open file $inpf!\n"; > > # read file > my (%idhash); > my $line; > while ($line = <DATA>) { > chomp($line); > > if ($line =~ /^dn:\s+uid=(s\d{2}-\d{1}-\d{1}-\d{1,3})/) { > my $id = $1; > my $recd = 1; > while ($recd == 1) { > if ($line =~ /^uidNumber:\s+(\d{4,})/ ){ > my $uid = $1; > $idhash{$id} = $1; > $recd = 0; > } > else { > $line = <DATA>; > chomp($line); > > } > } > } > > } > print Dumper(%idhash), "\n"; > > while ( (my $snum, my $sid) = each(%idhash) ) { > print "Student = $snum\tuidNumber = $sid\n"; > } > > END; > Thanks Ian On Mon, Aug 17, 2009 at 10:11 AM, Jyotishmaan Ray <jyotishmaan@yahoo.com>wrote: > Dear All, > > I have to read the uid from this file for each student entry, which is > itself a LDIF file, and extract it in another file, in a serial order. > > > Can you provide me the simplest way to do it. > > > > Thanks, > Jyotishmaan Ray > Moderator Of Spirituality-Paradise Group > http://yahoogroups.com/group/Spirituality-Paradise > > Are You Spiritually Aware !!! Are You Enjoying Yourself !!! See What All > You Had Been Missing !!!! > Please Join Immediately By Sending A Blank Mail @ > Spirituality-Paradise-subscribe@yahoogroups.com > > > > > > > -- > To unsubscribe, e-mail: beginners-unsubscribe@perl.org > For additional commands, e-mail: beginners-help@perl.org > http://learn.perl.org/ > > -- Ian http://www.cicsworld.comThread Previous | Thread Next