Leser: 1
![]() |
|< 1 2 >| | ![]() |
11 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/Perl/bin/perl
use strict;
use Data::Dumper;
use File::DosGlob;
my $dir = "C:/Dokumente und Einstellungen/pktm/*.*";
my $dir2 = "C:/*.*";
my @r = File::DosGlob::glob($dir);
print Data::Dumper::Dumper( \@r );
# Ausgabe: $VAR1 = [];
@r = File::DosGlob::glob($dir2);
print Data::Dumper::Dumper( \@r );
# Ausgabe = alle Dateien auf der Ebene
/home/user/datei\ name\ mit\ leerzeichen
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/Perl/bin/perl
use strict;
use Data::Dumper;
use File::Spec;
use File::DosGlob;
print "Version: " . $File::DosGlob::VERSION . "\n";
print "dir with spaces, Win32-OS (XP home), unix-slash-notation\n";
my $dir = "C:/Dokumente und Einstellungen/pktm/*.*";
print "dir: $dir \n";
my @r = File::DosGlob::glob($dir);
print "output:\n";
print Data::Dumper::Dumper( \@r );
print "\nnext: dir without spaces\n";
my $dir2 = "C:/*.*";
print "dir: $dir2 \n";
@r = File::DosGlob::glob($dir2);
print "output:\n";
print Data::Dumper::Dumper( \@r );
print "\nnext: dir with spaces and File::Spec\n";
my $dir3 = File::Spec->catfile("C:/Dokumente und Einstellungen/pktm/", '*.*');
print "dir: $dir3 \n";
@r = File::DosGlob::glob($dir3);
print "output:\n";
print Data::Dumper::Dumper( \@r );
# Vollständiger Output:
#Use of uninitialized value in substr at C:/Perl/lib/File/DosGlob.pm line 38.
#Version: 1.00
#dir with spaces, Win32-OS (XP home), unix-slash-notation
#dir: C:/Dokumente und Einstellungen/pktm/*.*
#output:
#$VAR1 = [];
#
#next: dir without spaces
#dir: C:/*.*
#
#output:
#$VAR1 = [
# 'C:/.cpan',
# ...lots of files...
# ];
#
#next: dir with spaces and File::Spec
#dir: C:\Dokumente und Einstellungen\pktm\*.*
#output:
#$VAR1 = [];
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/perl
use strict;
use warnings;
my $dir = 'C:\Dokumente und Einstellungen\pktm';
opendir(DIR,$dir) or die $!;
my @files = map{$dir.'\'.$_}grep{-f $_ && $_ =~ /\./}readdir(DIR);
closedir DIR;
print $_,"\n" for(@files);
QuoteSpaces in the glob denote multiple patterns. You must escape spaces that
are intended as literal spaces in the pattern. From the documentation
for File::DosGlob
Spaces in the argument delimit distinct patterns, so "glob('*.exe
*.dll')" globs all filenames that end in ".exe" or ".dll". If you want
to put in literal spaces in the glob pattern, you can escape them with
either double quotes, or backslashes. e.g. "glob('c:/"Program
Files"/*/*.dll')", or "glob('c:/Program\ Files/*/*.dll')". The argument
is tokenized using "Text::ParseWords::parse_line()", so see
Text::ParseWords for details of the quoting rules used.
Regards,
Randy.
Due to historical reasons, CORE::glob() will also split its argument on whitespace, treating it as multiple patterns, whereas bsd_glob() considers them as one pattern.
![]() |
|< 1 2 >| | ![]() |
11 Einträge, 2 Seiten |