I am breaking out in a sweat just looking at all that work you did for such a simple single-table commit to database. Have a look at a SQL::Catalog + DBIx version of the same code
package DBH; use strict; use DBIx; use constant DBI_DSN => 'DBI:vendor:database:host'; use constant DBI_USER => 'user'; use constant DBI_PASS => 'pass'; my $DBH; sub import { unless (ref $DBH) { $DBH = DBI->connect( DBI_DSN, DBI_USER, DBI_PASS, {RaiseError => 1} ); } $DBIx::DBH = $DBH; } 1; package main; use DBH; # creates database handle via import() ### initialize + config code un-necessary ### not with SQL::Catalog + DBIx ### and not, as mentioned in the conclusion ### with DBIx::Recordset ### and probably not Alzabo either find sub { return unless m/\.mp3$/; my $tag = get_mp3tag($_) or return; my %tag = %$tag; # sql_do finds the $dbh for you... sql_do sql_lookup 'insert_mp3_tag_data', @tag{title artist album year genre} ; }, @ARGV;

Also, consider that your entire example would be a DBIx::Recordset one-liner. I think I will contact Dave Rolsky and coax him into posting an Alzabo version. Then every person who is actively working on database frameworks will have an example here.


In reply to SPOPS compared with SQL::Catalog + DBIx by princepawn
in thread Save MP3 Tag's to Database with SPOPS by jeffa

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.