Thread regex mit 2 Variablen (7 answers)
Opened by Gast at 2008-12-12 18:54

Gast Gast
 2008-12-12 19:31
#117135 #117135
hm stimmt... wen ichs so mache gehts...
Also ich habe folgenden Code
Code (perl): (dl )
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
use strict;
use warnings;
#---to configure---
#MySQL DB setting
my $user = 'bla';
my $password = 'bla';
my $host = 'localhost';
my $database = 'bla';
my $table = 'bla';
#else
my @paths = ('/home/matthias/Videos','/mnt/next/g/multimedia/filme','/home/matthias/ttt');
my @fileformats = ('avi','mpg','mpeg','bin');
#---to configure end---
my $check;
my $file;
for my $path (@paths) {         
        if(-d $path){
                search($path);
        }else{
                logP->wirteLog("Path ".$path." don't exist\n");
        }
}
                
sub checkFileFormat{
        my $file = shift;
        for my $fileformat (@fileformats){
                if($file =~ m/($fileformat)/){$check=1;}
                else{$check=0;}
        }
}               
                
sub search{
        local *DIR;
        my $path = shift;
        opendir(DIR,$path);
        while($file = readdir(DIR)) { 
                if(($file ne ".") && ($file ne "..")){
                        if(-d $path."/".$file){                         
                                search($path."/".$file);
                        }else{
                                checkFileFormat($file);
                                if($check==1){
                                        print($check." ".$path."/".$file."\n");
                                }else{
                                        print($check." ".$path."/".$file."\n");
                                }
                        }
                }
        }
        closedir(DIR);
}


aber so wird $check IMMER 0 :(

View full thread regex mit 2 Variablen