in reply to how to use regexes in SELECT statement

As Herkum suggested, you can't simply use Perl regexes in SQL. But based on what you're trying to do, you probably don't need regexes anyway. You can use LIKE. Also, you're best off binding your params rather than including variables in your SQL:
my $data = qq( SELECT catname, path FROM categories WHERE path LIKE ? AND path != ? ); my $sth = $dbh->prepare($data); $sth->execute( "$path/%", $path ) or die $dbh->errstr;