I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2008-10-01 12:55:37-07 by mmain
Fedora Core 5 to Fedora Core 9 DBI mysql problems
After a recent hard disk failure I have had to upgrade from FC5 to FC9 and a casualty of this transition is a perl script that I used to trawl the disk space for mp3 files to catalog these in a mysql database. Following the transition, nearly all of the database access methods appear to gave deprecated and there is virtually no documentation around to explain these changes or alternatives. For example, query, numrows, affectedrows fetchhash no longer work. Any advice or where to look much appreciated
# SQL connect my $db = Mysql->connect($conf::sql_host,$conf::sql_db, $conf::sql_user,$conf::sql_pass); die "can't connect to MySQL server ($conf::sql_host)" if !defined($db); $|=1; # make your pipes pipe hot my ($query,$st,%data,%dbfiles,@ids,@files); my ($add,$del,$nop); while (my $arg = shift) { if ($arg eq "-del") { $query = sprintf("delete from mp3main where filename like %s", $db->quote((shift) . "%")); $st = $db->query($query); printf "%d records deleted\n",$st->affectedrows; exit; } if ($arg eq "-add") { @conf::mp3path = (); push @conf::mp3path,shift; } } foreach my $dir (sort @conf::mp3path) { # init undef %dbfiles; undef @ids; $add = 0; $del = 0; $nop = 0; print "*** scanning $dir ***\n"; # query all matching files $query = sprintf("select id,filename from mp3main where filename like %s", $db->quote($dir . "%")); $st = $db->query($query); for my $i (1 .. $st->numrows) { %data = $st->fetchhash; $dbfiles{$data{filename}} = $data{id}; } # look for new files and verify the existing ones if ($dir =~ /^http:/) { @files = spider($dir); } else { @files = find_mp3($dir); } foreach my $file (@files) { if (defined($dbfiles{$file})) { # print "found: $file\n"; $nop++; } else { print "new : $file\n"; add_file($db,$file); $add++; } delete $dbfiles{$file}; } # delete stale entries foreach my $file (keys %dbfiles) { print "gone : $file\n"; push @ids,$dbfiles{$file}; $del++; } if ($#ids != -1) { $query = "delete from mp3main where id in (" . join(",",@ids) . ")"; $db->query($query); } # statistics print "$add new files, $del files gone, $nop up-to-date entries found\n"; }
Direct Responses: Write a response