Thread Aufbereitung eines Directory-Inhalts zur Auswahl: Directory-Inhalt zur Auswahl anbieten (10 answers)
Opened by Gast at 2006-08-23 14:16

Ronnie
 2006-08-23 14:55
#69143 #69143
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
okay, dann hier mal ein Ansatz:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl

use strict;
use warnings;

my @txt_files = <*.txt>;

for (0..$#txt_files) {
print $_ . ")\t" . $txt_files[$_] . "\n";
}

print "Bitte wählen sie eine Datei aus: ";
my $sel = <STDIN>;
chomp($sel);
die "Keine gültige Eingabe!\n" unless $sel =~ /^\d+$/;
print $sel . "\t--\t" . $txt_files[$sel] . " wurde ausgewählt!\n";

EDIT: Danke an renee --> regex geƤndert!\n\n

<!--EDIT|Ronnie|1156331729-->

View full thread Aufbereitung eines Directory-Inhalts zur Auswahl: Directory-Inhalt zur Auswahl anbieten