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

Hallo Zusammen,

ich habe ein kleines vllt. auch großes (dass kann ich noch nicht absehen :confused: ) Problem in Perl.

Habe eine Subroutine, die mir einen Array zurück gibt. Ich möchte nun auf die einzelnen Teile des Returnwertes zugreifen.

Nur leider weiß ich nicht, wie das machen muss :(

Wäre super wenn mir da jemand Helfen könnte.

Hier der Code:


sub open_dir {


	#Variablendeklaration

	my @content = ();

	my $directory = shift;


	#Verzeichnis oeffnen

	opendir(DIR, $directory);


	#Inhalte des Verzeichnisses in ein Array speichern

	while(my $file = readdir(DIR)) {

		push(@content, $file);

	}


	#Verzeichnis schließen

	close(DIR);


	return @content;


}


print open_dir("d:\\test1");

Ich muss dazu sagen, dass ich noch ein Neuling in Sachen Perl bin :rolleyes:

Grüße

Michl

@content = open_dir(...);

print $content[0];

print $content[1];


$length = @content;


for($i = 0; $i < $length; $i++)

{

print $content[$i];

}

Danke erstmal für die Antwort, aber ich kann damit leider ned soviel anfangen.

Könntest du des vllt. kurz erklären?

Weil irgendwie trifft des nicht den Nerv meines Problems oder kann es nur nicht erkennen...

Ich bin jetzt zufällig selbst über des Rätsels Lösung gestolpert. :) Folgendermaßen muss man es machen:

my @versuch = open_dir("d:\\test1");
So kann ich jetzt jedes Teilelement, dass die Funktion open_dir() in dem Array @content speichert ganz einfach ansprechen, also mit
print $versuch[0...n];

Trotzdem danke für euere Hilfe...

Grüße

Michl

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.