this code querys a cddb (in thie ex: freedb, via the freedb.pm) and inserts the important info in an sql table. this is the first script im halfway proud of. Im sure there are errors, but it works for me... :]
#!/usr/bin/perl -w use strict; use FreeDB; use DBI; ### DBI shit my $DBhost = "localhost"; my $DBport = "3306"; my $DBdb = "cd"; my $DBtable = "list"; my $DBuser = "cdlist"; my $DBpassword = "cdlist"; my $cd = new FreeDB; $cd->ignore_cache(0); if (!$cd->fetch) { print "couldn't fetch cd info\n"; exit 1; } else { print "Artist => ", $cd->artist, "\n"; print "Title => ", $cd->title, "\n"; while ($cd->next_track) { print "Track number => ", $cd->current_track_number_padded, +". "; print $cd->current_track_info, " ("; print $cd->current_track_time_in_minutes, ")\n"; } insert_cd(); } sub insert_cd { my $dbh = DBI->connect("DBI:mysql:database=$DBdb; host=$DBhost;po +rt=$DBport" , $DBuser , $DBpassword); my $sth = $dbh->do("INSERT INTO $DBtable(discid,artist,title,trac +knum,seconds) VALUES(?,?,?,?,?)", undef, $cd->discid, $cd->artist, $c +d->title, $cd->total_tracks, $cd->disc_length); $dbh->disconnect; system('eject'); return; }

In reply to cddb to mysql script. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.