Hi,
mal davon abgesehen, dass in deinem Codestück Fehler drin sind und
auch eine Stelle da ist, die ich nicht verstehe, klappt es bei mir
hervorragend!
Fehler: $$name, $$doc_format
Unverständlich: my $doc_format = shift;
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
#> ls -1
file.doc
file.odt
file.txt
test.pl
#> cat test.pl
#!/usr/bin/perl
use strict;
use warnings;
use File::Basename;
use Data::Dumper;
sub get_format{
my $suffix;
my @files;
my $name = shift;
my $doc_format = shift;
my $srcdir = shift;
foreach my $f (glob( $srcdir."$name.*" ) ) {
my ($basename, $path, $ext ) = fileparse ( $f, "\..+" );
next if $ext =~ /(JPL|a00)$/;
push( @files, $f );
}
foreach my $ele (@files){
my @s = split(/\./,$ele);
$doc_format = $s[1];
}
return \@files;
}
my $files = get_format('file', '', './');
print Dumper($files);
#> ./test.pl
$VAR1 = [
'./file.doc',
'./file.odt',
'./file.txt'
];
Gruss,
opi\n\n
<!--EDIT|opi|1161152983-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.