=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/lib/OpenBSDTorrents.pm,v retrieving revision 1.12 retrieving revision 1.15 diff -u -r1.12 -r1.15 --- openbsd/OpenBSDTorrents/lib/OpenBSDTorrents.pm 2010/03/22 20:08:48 1.12 +++ openbsd/OpenBSDTorrents/lib/OpenBSDTorrents.pm 2010/05/26 20:41:15 1.15 @@ -1,5 +1,5 @@ package OpenBSDTorrents; -#$RedRiver: OpenBSDTorrents.pm,v 1.11 2010/03/03 21:15:20 andrew Exp $ +#$RedRiver: OpenBSDTorrents.pm,v 1.14 2010/05/19 22:19:43 andrew Exp $ use 5.008005; use strict; use warnings; @@ -13,7 +13,7 @@ our @EXPORT = qw( $OBT $INSTALL_ISO_REGEX - $SONGS_REGEX + $SONG_REGEX &Name_Torrent &Get_Files_and_Dirs &justme @@ -21,8 +21,8 @@ my $config_file = '/etc/OpenBSDTorrents.conf'; our $OBT = Config(); -our $INSTALL_ISO_REGEX = qr/install\d+\.iso/xms; -our $SONGS_REGEX = qr/^(song.*\.([^\.]+))$/xms; +our $INSTALL_ISO_REGEX = qr/ \b install\d+\.iso \b /xms; +our $SONG_REGEX = qr/^song.*\.([^\.]+)$/xms; sub Config { @@ -63,6 +63,12 @@ sub Get_Files_and_Dirs { my $basedir = shift; + + if ( -f $basedir ) { + $basedir =~ s{^.*/}{}xms; + return [], [ $basedir ]; + } + opendir DIR, $basedir or die "Couldn't opendir $basedir: $!"; my @contents = sort grep { ! /^\.\.$/ } grep { ! /^\.$/ } readdir DIR; closedir DIR;