[linux-support] Perl

Markus Wernig markus at wernig.net
Thu Oct 2 18:44:26 CEST 2003


On Thu, 2003-10-02 at 16:46, Markus Wernig wrote:
> On Thu, 2003-10-02 at 08:56, Kissling Lucas wrote:
> > Hallo
> > Hallo Lukas
Noch eine kleine Reparatur, damit die while()-Schleife sicher problemlos
funktioniert.
> 
> > 
> > #!/usr/bin/perl
> > use Text::ParseWords;
> > $objectclass0 = 'person';
> > $objectclass1 = 'inetOrgPerson';
> > $objectclass2 = 'top';
> > 
> > $suffix = 'ou=Personen, o=BCO, o=Meine Org,dc=COM';
> > while ($line = <STDIN>) {
> >   @fields = &quotewords(',',0,$line);
> > 
> >   # Set variable values based on the array values.

$OISC=$/;	  # save old input separator

> $/ = " ";	# set input separator for chomp(), so it will truncate
> 		# empty fields which have " "
> >     
> chomp($cn         = ($fields[2]?$fields[2]:undef));
> chomp($fname      = ($fields[1]?$fields[1]:undef));
> chomp($lname      = ($fields[2]?$fields[2]:undef)); # Achtung: wirklich $fields[2]???
> chomp($title      = ($fields[0]?$fields[0]:undef));
> 
> [... und so weiter fuer alle Werte ...]
> 
> >   # Output.
> print "dn: cn=$fname $lname,$suffix\n" if ($fname and $lname and $suffix);
> print "objectclass: $objectclass0\n" if $objectclass0;
> print "objectclass: $objectclass2\n" if $objectclass2;
> print "objectclass: $objectclass1\n" if $objectclass1;
> 
> [... und so weiter fuer alle Werte ...]

$/=$OISC;

> > }
> > 
> > exit;

mfg /m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://www.lugbe.ch/vpipermail/linux-support/attachments/20031002/93b86883/attachment.bin


More information about the Linux-support mailing list