You have nested single quotes (')s
I'm sorry I don't currently have access to a database to test this against, but I believe this should work:
my $sth = $dbh->prepare(q~
select
smt.uniqueid, smt.creationtime, att.name, att.val, gsm.msisdn
from
dagenericsmt smt, dagenericsmtattribute att, dagsmproduct gsm
where smt.uniqueid = att.genericsmt_uniqueid
and smt.product_uniqueid = gsm.uniqueid
and smt.smtstatus=2
and smt.smtcommand=3
and att.name in ('GSM/Cur/IMSI','GSM/Rpl/IMSI')
and smt.acktime is null order by smt.uniqueid
~)
Also - when you're posting code - if you use <code> ... </code> tags around the code it will format it correctly for you and make it downloadable.
It's also easier for us (and you) to read if you can split it up and indent it some logical way. :o)
Update: (like dragonchild's *beautiful* example below - definitely gets my ++!)