| version 1.10, 2007/11/02 03:36:01 |
version 1.11, 2010/03/03 21:15:20 |
|
|
| package OpenBSDTorrents; |
package OpenBSDTorrents; |
| #$RedRiver: OpenBSDTorrents.pm,v 1.9 2006/05/15 18:47:04 andrew Exp $ |
#$RedRiver: OpenBSDTorrents.pm,v 1.10 2007/11/02 02:36:01 andrew Exp $ |
| use 5.008005; |
use 5.008005; |
| use strict; |
use strict; |
| use warnings; |
use warnings; |
|
|
| # bit safer, but I can't think of what would work here. |
# bit safer, but I can't think of what would work here. |
| if ($val =~ /^(.*)$/) { |
if ($val =~ /^(.*)$/) { |
| $config{$name} = $1; |
$config{$name} = $1; |
| |
$config{$name} =~ s/^['"]|["']$//gxms; |
| } |
} |
| } |
} |
| close FILE; |
close FILE; |
|
|
| opendir DIR, $basedir or die "Couldn't opendir $basedir: $!"; |
opendir DIR, $basedir or die "Couldn't opendir $basedir: $!"; |
| my @contents = sort grep { ! /^\.\.$/ } grep { ! /^\.$/ } readdir DIR; |
my @contents = sort grep { ! /^\.\.$/ } grep { ! /^\.$/ } readdir DIR; |
| closedir DIR; |
closedir DIR; |
| my @dirs = grep { -d "$basedir/$_" } @contents; |
|
| |
|
| my %dirs; # lookup table |
my @dirs; |
| my @files;# answer |
my @files; |
| |
ITEM: foreach my $item (@contents) { |
| # build lookup table |
if ( -d "$basedir/$item" ) { |
| @dirs{@dirs} = (); |
if ( $OBT->{SKIP_DIRS} |
| |
&& $item =~ /$OBT->{SKIP_DIRS}/) { |
| foreach my $item (@contents) { |
next ITEM; |
| push(@files, $item) unless exists $dirs{$item}; |
} |
| |
push @dirs, $item; |
| |
} |
| |
else { |
| |
if ( $OBT->{SKIP_FILES} |
| |
&& $item =~ /$OBT->{SKIP_FILES}/) { |
| |
next ITEM; |
| |
} |
| |
push @files, $item; |
| |
} |
| } |
} |
| |
|
| @dirs = grep { ! /$OBT->{SKIP_DIRS}/ } @dirs |
|
| if $OBT->{SKIPDIRS}; |
|
| @files = grep { ! /$OBT->{SKIP_FILES}/ } @files |
|
| if $OBT->{SKIP_FILES}; |
|
| |
|
| return \@dirs, \@files; |
return \@dirs, \@files; |
| } |
} |