![]() |
![]() |
5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# get_format holt sich über den namen der Datei das Format des document
sub get_format{
use strict;
use warnings;
use File::Basename;
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];
}
}
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'
];
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/perl
use strict;
use warnings;
my $test = 'Hallo';
test(\$test);
print $test;
sub test{
my $ref = shift;
$$ref = 'test';
}
QuoteFor example, @$aref is the same as @{$aref} , and $$aref[1] is the same as ${$aref}[1] .
![]() |
![]() |
5 Einträge, 1 Seite |