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.

[PERL] and-operator

Empfohlene Antworten

Veröffentlicht

Hi,

ich habe hier einen sql dump in welchem ich die Umlaute durch die HTML Tags ersetzten will. So hab ich das bisher gelöst:


	$line =~ s/ü/ü\;/og;

	$line =~ s/Ü/Ü\;/og;

	$line =~ s/ä/ä\;/og;

	$line =~ s/Ä/Ä\;/og;

	$line =~ s/ö/ö\;/og;

	$line =~ s/Ö/Ö\;/og;

	$line =~ s/ß/ß\;/og;

Ich hätte das aber gerne in einer Zeile mit "and" verknüpft, was dann so aussehen sollte:

	($line =~ s/ü/ü\;/og) and ($line =~ s/Ü/Ü\;/og) and ($line =~ /ä/ä\;/og) and ($line =~ s/Ä/Ä\;/og) and ($line =~ s/ö/ö\;/og) and ($line =~ s/Ö/Ö\;/og) and	($line =~ s/ß/ß\;/og);

Beim zweiten Beispiel wird aber nur die erste klammer (ü's ersetzen) ausgeführt, woran liegt den das?

Gruß und Danke

Beim zweiten Beispiel wird aber nur die erste klammer (ü's ersetzen) ausgeführt, woran liegt den das?

Wie in den meisten Sprachen wird ein

a AND b AND c

nur ausgeführt wenn der Ausdruck a wahr ist. Ist er ist nicht, so ist der ganze Ausdruck eh falsch und der Vorgang wird abgebrochen.

Was du hier willst ist kein logisches AND sondern du willst a und b und c Ausführen.

Was du hier eigentlich willst ist eher ein

use HTML::Entities


use HTML::Entities;


my $line = encode_entities($line);


~> perl -Mutf8 -MHTML::Entities -e '$line = "äöüÄÖÜ"; $line = encode_entities($line); printf("%s\n",$line);'

äöüÄÖÜ

Hi,

danke für den schnellen Hinweis, ich werde mir merken das es dieses Modul gibt :) Sollte ich nochmal das Problem haben, werd ich es damit lösen!

Gruß

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.