From 0129cd78f1516df6d2af2a2eb81b58a039bfb1b5 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Fri, 17 Feb 2012 22:57:13 +0100 Subject: prefix --- videodb-check.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'videodb-check.pl') diff --git a/videodb-check.pl b/videodb-check.pl index 11c5de2..14d58ed 100755 --- a/videodb-check.pl +++ b/videodb-check.pl @@ -24,7 +24,8 @@ my %config = do $confile; die "Error in `" .$confile. "'\n" if $@ || not %config; map { exists $config{$_} || die "Error: Missing `${_}'.\n" } - qw /videodir driver database hostname user port password videodata/; + qw /videodir driver database hostname user port password/; +$config{prefix} = "" unless exists $config{prefix}; my $symlinks = catdir($config{videodir},'MOVIES'); # Symlinks folder die "Error: No such directory: `" .$symlinks. "'.\n" unless -d $symlinks; @@ -105,7 +106,7 @@ e.g., user => 'username', port => 3306, password => '******', - videodata => "videodb_videodata", + prefix => "videodb_", =head1 EXIT STATUS @@ -149,7 +150,7 @@ $dbh->do( "set names utf8" ) or die; # valid target my $r = 0; # Exit status -my $res = $dbh->selectall_arrayref ( "SELECT filename,director FROM $config{videodata}" ) +my $res = $dbh->selectall_arrayref ( "SELECT filename,director FROM $config{prefix}videodata" ) or die "Can't select: " .$dbh->errstr. "\n"; @@ -214,7 +215,7 @@ closedir(DIR) or die "Can't close: $!\n"; undef @files; -my $sth = $dbh->prepare ( "SELECT id FROM $config{videodata} WHERE filename = ?" ) +my $sth = $dbh->prepare ( "SELECT id FROM $config{prefix}videodata WHERE filename = ?" ) or die "Error: " .$dbh->errstr; foreach (@filelist) { $sth->execute ($_) or die "Can't select: " .$dbh->errstr. "\n"; @@ -255,7 +256,7 @@ sub report { sub check { my $bad = $dbh->selectall_arrayref( "SELECT filename - FROM $config{videodata} + FROM $config{prefix}videodata WHERE " .$_[1] ) or die "Can't select: " .$dbh->errstr. "\n"; &report ("The following files have " .$_[0], [map {$_->[0]} @$bad]); -- cgit v1.2.3