When I have done this type of task, I've broken it up into several discrete portions and stitched them together using a shell script. Right now, I have a daily load from a sub-optimally normalized Oracle database into a MySQL database (for generating reports). I use the following process:
- Oracle's SQL*Plus connections kicked off from command-line to generate tab-delimited data files
- A cleanup step to make sure all backslashes are backslashes, there's a \N for empty datafields, and the like. This a shell script that calls Perl in commandline.
- MySQL's client is kicked off in batch mode. I have to do some massaging of the data, as well, so I need to use MySQL.
While all of those things could've been done in Perl, it's a lot quicker to do it in the native client. And, the reason I wrote the second step as a shell script around commandlines is that it's easier to do
#!/bin/sh
foreach f in *.xsv
loop
perl -pi -e 's/asdf/jkl;/g' $f
endloop
than it is for me to open the file, loop through all the lines, and write the file back out. Why make it harder for yourself?
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.