1 2 3 4 5 6 7 8 9 10 11
#! c:/perl/bin/perl.exe -w print "\nPlease put in the folder you want to search for files, like example underneath\n"; print "Example for windows 'c:/.../.../.../': "; chomp(my $dirname = <STDIN>); opendir (DIR, $dirname) or die "\nError $!\n"; @dir = readdir(DIR); #if (@dir = 0) { #if Funktion sollte einen Error anzeigen wenn Verzeichnis leer ist - #funktioniert nicht # print "\nSorry no files in the folder!\n"; # } print join("\n", @dir); closedir DIR;
# Dein Perl-Code hier
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#! c:/perl/bin/perl.exe use strict; print "\nPlease put in the folder you want to search for files, like example underneath\n"; print "Example for windows 'c:/.../.../.../': "; chomp(my $dirname = <STDIN>); opendir (DIR, $dirname) or die "\nError $!\n"; #opens the directory or brings back an error while (my $name = readdir DIR) { next if $name =~ /^\./; #excludes the Files . and .. from the list my @attr = stat($name); if ($attr[7] <= 0) { print "Oimitting Directory $name\n"; } else { my $mtime = localtime($attr[9]); print "$name $attr[7] bytes modified: $mtime\n"; }} closedir DIR;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/usr/bin/perl use warnings; use strict; use Cwd; sub myfind { my $wd = shift; my @a = <*>; my @dirs = (); my $i; foreach $i (@a) { $i = "$wd/$i"; if (-d $i) { push(@dirs, $i); } } my $adir; foreach $adir (@dirs) { print "$adir\n"; myfind($adir); } } myfind(getcwd());