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] Hash auslesen

Empfohlene Antworten

Veröffentlicht

Hallo,

ich habe hier einen Hash und würde einfach gern

den Inhalt verschiedener Keys ausgeben,

aber egal was ich versuche, ich kriegs nicht hin. :(

Hier erstmal der Hash:


#!/usr/bin/perl -w


my $obst =   {   

                "Apfel"   	=>    	["gelb", "gruen", "rund"],

                "Birne"		=>	["gelb", "gruen", "birnig", "FSInodeUsedPercent", "FSUsedSpace"],

		"Orange"	=>	["orange", "zermatscht", "rund"]

		};


my $pizza = {

                "Margaritha"    =>  "basic",

                "Salami"	=>  "Wurst",

                "Funghi"        =>  "Thunfisch"

                };

Wie muss ich es nun anstellen wenn ich bestimmte

Werte einfach auf dem Bildschirm dargestellt haben will,

z.B. alle Werte des Keys "Apfel".

Hab bei google zwar viel gefunden aber funktioniert

hat das irgendwie alles nicht.

Danke für eure Hilfe :)

  • Autor

Hab es mit Hilfe anderer rausbekommen :)


# mach das für alle Elemente des Arrays


while(@array=each(%obst))

{

#schlüssel nach $array[0] und Wert nach $array[1]


#Ausgabe des Hash Wertepaares


print "$array[0] => $array[1]\n";	


#p ist Zeiger auf das array in $array[1], welches oben als ein Element des hashes initialisiert wurde


    $p=$array[1];


#Ausgabe aller werte in dem array, auf das p zeigt


        foreach(@$p)

	{


#ausgabe des Array-Elementes mit Zeilenumbruch


		print "$_\n";

	}

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.