version 1.12, 2010/03/22 20:08:48 |
version 1.14, 2010/05/19 23:19:43 |
|
|
package OpenBSDTorrents; |
package OpenBSDTorrents; |
#$RedRiver: OpenBSDTorrents.pm,v 1.11 2010/03/03 21:15:20 andrew Exp $ |
#$RedRiver: OpenBSDTorrents.pm,v 1.13 2010/03/22 20:13:53 andrew Exp $ |
use 5.008005; |
use 5.008005; |
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
our @EXPORT = qw( |
our @EXPORT = qw( |
$OBT |
$OBT |
$INSTALL_ISO_REGEX |
$INSTALL_ISO_REGEX |
$SONGS_REGEX |
$SONG_REGEX |
&Name_Torrent |
&Name_Torrent |
&Get_Files_and_Dirs |
&Get_Files_and_Dirs |
&justme |
&justme |
|
|
my $config_file = '/etc/OpenBSDTorrents.conf'; |
my $config_file = '/etc/OpenBSDTorrents.conf'; |
our $OBT = Config(); |
our $OBT = Config(); |
our $INSTALL_ISO_REGEX = qr/install\d+\.iso/xms; |
our $INSTALL_ISO_REGEX = qr/install\d+\.iso/xms; |
our $SONGS_REGEX = qr/^(song.*\.([^\.]+))$/xms; |
our $SONG_REGEX = qr/^song.*\.([^\.]+)$/xms; |
|
|
sub Config |
sub Config |
{ |
{ |
|
|
sub Get_Files_and_Dirs |
sub Get_Files_and_Dirs |
{ |
{ |
my $basedir = shift; |
my $basedir = shift; |
|
|
|
if ( -f $basedir ) { |
|
$basedir =~ s{^.*/}{}xms; |
|
return [], [ $basedir ]; |
|
} |
|
|
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; |