If you have to do this again, and for some reason can't use the DBI module to connect to MySQL (which makes this problem easy!), you might try looking at the built-in mysql tool 'mysqldump'. It's a much better design for getting this kind of data dump - you can specify your own field separators, and basically have a lot more options that might make things signifigantly easier to format.

Of course, if you _can_ run a perl script on a machine that is allowed to talk to the MySQL database (and you can configure MySQL to allow particular remote machines in - it's mildly complex, but the docs on mysql.com do spell it out), then things become nice. Use the DBI module, and you can read the fields directly into an array, which allows you to take full advantage of perl's formatting.

Not that your script isn't useful - I've written similar, to get to a brio database in the unfortunate past - but with mysql, you hopefully don't have to work that hard.

-- Kirby

Tuxtops: Laptops with Linux!


In reply to RE: Straighten MySQL Table Displays by kirbyk
in thread Straighten MySQL Table Displays by maloi

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.