> my $sth = $dbh->prepare("select sid from v_$session"); Your problem is that you enclosed your SQL statement with double qoutes. This way, your table name becomes just 'v_' (as there is not any defined variable $session in your program.) See perl's error message and find what it is tring to tell you about variable $session.
Please note, that in double quotes, perl does variable expansion so any character '$' should be escaped. As an alternative, you could use single quote (or q{}), for example: my $sth = $dbh->prepare('select sid from v_$session'); or my $sth = $dbh->prepare(q{select sid from v_$session}); Waldemar