#!/opt/local/bin/perl use DBI; print "\nPerl says hello.\n\n"; my $dsn = 'DBI:mysql:music_app:localhost'; my $db_user_name = 'music_app'; my $db_password = 'music_app'; my $db = DBI->connect($dsn, $db_user_name, $db_password); my @genres= ("Rap", "Jazz", "Punk", "Reggae"); my $sql = qq{ SELECT songs.title FROM songs,genres WHERE songs.genre_id = genres.id AND genres.name = ? }; my $sth = $db->prepare($sql); for(@genres) { $sth->bind_param(1, $_, {TYPE => SQL_VARCHAR}); $sth->execute(); my($title); $sth->bind_columns(undef, \$title); print "$_\n"; while( $sth->fetch() ) { print "$title\n"; } print "\n\n"; } $sth->finish(); $db->disconnect();