Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi @all,

ich hab hir mal ein Auschnitt, au meinen Perlskipt:


while (<USERLIST>){

chomp;

# +++ schreiben in die "LdapAddHost.ldif" +++

print LDAPADDHOSTFILE grep (/^dn:/,$_ . "\n" .

                                    "changetype: modify" . "\n" .

                                    "add: host" . "\n" .

                                    "host: $HOSTNAME" . "\n\n");

}
Die while Schleife liest über ein DateiHeandle USERLIST Zeile für Zeile ein. Wenn diese Zeile jetzt mit "dn:" Anfängt, dann wird das in einer Datei mittels dem Dateiheandle LDAPADDHOSTFILE geschrieben. Am schluss wird in etwa so eine Datei erzeugt:
dn: uid=testuser,ou=users,o=neptun,c=de

changetype: modify

add: host

host: hostname

Jetzt wollt ich mal fragen, ob ich print Zeile etwas anders gestallten könnte bzw. wie ich das machen könnte?

Man könnte das Ganze vor allem performanter machen. Der String für die Ausgabedatei wird ja immer generiert auch wenn die Zeile danach nicht ausgegen wird. Aussehen könnte das Ganze z.B. auch so:


while(my $line = <USERLIST>) {

  if($line =~ m/^dn:/o) {

    chomp $line;

    my $ldifstring = join "\n",

      $line,

      'add: host',

      'host: ' . $HOSTNAME,

      '';

     print LDAPADDHOSTFILE $ldifstring;

  }

}

Wer's kompakter mag kann das Ganze natürlich auch wieder abkürzen:

print LDAPHOSTFILE $_, join("\n", 'add: host', 'host: ' . $HOSTNAME, '')

  if $_ =~ m/^dn:/o while <USERLIST>;

Dann ist's halt wieder nur noch eine Zeile...

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.