in reply to Integrating System commands with regex's
my $regex = { 'txt' => qr{.*txt$}i, 'conf' => qr{.*conf$}i # ... and so on }; opendir DH, '.'; while(my$file=readdir(DH)){ for (keys %$regex){ if ($file =~ /$regex->{$_}/){ print "$file has ", uc$_, " ext\n" } } }
|
|---|