Man, DBIx::Recordset is sah-weet. No mind-entangling string operations, just a hash with slots for the things I need to do... In all honesty I like to code straight SQL since starting my read of SQL Queries for Mere Mortals but I hate trying to turn Perl data structures into SQL.
use strict; use Data::Dumper; use DBIx::Connect; use DBIx::Recordset; $DBIx::Recordset::Debug = 2; my @scf = (902 .. 908, 917, 926 .. 928); # scf is a zip prefix use vars qw(*zipset); *zipset = DBIx::Recordset->Search ({ '!DataSource' => DBIx::Connect->to('mdb_test'), '!Table' => 'customer', '*zip' => 'LIKE', 'zip' => [ map { $_ . '%' } @scf ], '$max' => 10 }); my $count; while (my $rec = $zipset->Next) { print Dumper($rec); exit if ++$count > 10; }

And the debugging output to make sure everything is copacetic:

tbone@MDB:/data/tbone/maldunn/204209-007 perl query.pl DB: Use already open dbh for database=test;host=localhost (id=1, numO +pen = 0) DB: 'SELECT * FROM customer WHERE ( (zip LIKE ?) or (zip LIKE ?) + or (zip LIKE ?) or (zip LIKE ?) or (zip LIKE ?) or (zip LIKE + ?) or (zip LIKE ?) or (zip LIKE ?) or (zip LIKE ?) or (zip L +IKE ?) or (zip LIKE ?)) LIMIT 0,11' bind_values=<902% 903% 904 +% 905% 906% 907% 908% 917% 926% 927% 928%> bind_types=<12 12 12 12 12 + 12 12 12 12 12 12> $VAR1 = { ... }; $VAR1 = { '... };

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality.


In reply to Check out my Recordset by princepawn

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.