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] farbige Ausgabe

Empfohlene Antworten

Veröffentlicht

Hi,

hab n Perlskript des ne ganze menge an Datensätzen aus einer DB ließt und dann ausgibt. Da es Formatierungsvorgaben gibt ist es teils unübersichtlich und man weiß nicht genau welcher Wert zu welchem Attribut gehört. Daher dachte ich mir, ich mach diese Ausgabe farbig.

aber irgendwie klappt das ganze nicht so richtig:

mit [k]Term::ANSIColor[/k] soll man die Colorbefehle verwenden können.

mit [k]print color 'blue';[/k] sollen alle folgenden Ausgaben blau sein.

mein Code:


foreach $data (@attribute) {

		my ($attid, $attval, $attname) = @$data;

		if($switch == 0){

			print color "blue";

			$switch = 1;

		}

		elsif($switch == 1){

			print color "reset";

			$switch = 0;		

		}

		$retval = $retval . sprintf("%-${id_len}s  =  %-${val_len}s  (%s)\n", $attid, $attval, $attname);


	}#foreach my $data (@attribute)

$switch is meine wechselvariable das die zeilen abwechselnd farbig sind (blue erstma zum testen. $retval is der string den die funktion zur ausgabe liefert. 2 Fragen: 1. Funktioniert es überhaupt wenn ich den string dort zwar definire und mit sprintf formatiere, aber garnicht ausgebe? 2. Wieso werden die Farbdefinietionen ausgegeben oohne umgewandelt zu werden?
←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m←[0m←[34m

dumme frage: hast schon "use Term::ANSIColor;" dam Anfang oder?

dann würd ich eher auch ein Syntax Problem tippen... z.B. schreib die Farbe mal in klammern, also so ("blue")

hab use term::ansicolor und win32:console da liegts nich dran.

es soll laut aussage anderer personen daran liegen das die ansiunterstützung nicht aktiv ist, hab sogar ne erklärung gefunden wies geht, nur muss man dazu aufs %systemroot% und da dürfen wir nich hin...

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.