i'm a dba and just started learning perl (and programming) about week ago...i am hoping some kind soul will help me out.

i'm working on a script to take the results of a benchmark result text file, parse the text, then toss it into a mysql database. the text file is composed of six columns and is many lines long. an example of a line is: count_distinct 25.00 0.48 0.12 0.60 1000

in pseudoCodeSpeak, i wanna grab the file, pass it into an array, grab the first line, parse the line into its six elements, write them to a row in a mysql table which i've already created, then do it again for the next line, then the next, and so on and so forth until there are no lines left. the mysql insert using perl is no big deal, i found an example that works that i'm trying to adapt - but the perl i have is very much incomplete, like there is no reference to the subroutine yet :)

any help is greatly, greatly appreciated. i'm planning on learning perl one step at a time, but i really need this to work soon and i'm sorta stuck in a mental rut...

Thanks in advance for any assistance!!!!

this is what i have so far:
use DBI; ###### connect to the database my ($dbh,$sth,$count); $dbh = DBI->connect ("DBI:mysql:host=boognish;database=benchwarmer", "joda","waliays", {PrintError => 0, RaiseError => 1}); ###### name, input, and read the text into an array $input_file = 'RUN-mysql-win2k.txt'; open(INFO, $input_file); @input = <INFO>; ###### slice the array input into six element chunks @input[0,1,2,3,4,5]=@single_line #assign values to the various parts of the single_line array $operation=$single_line[0]; $seconds=$single_line[1]; $usr=$single_line[2]; $sys=$single_line[3]; $cpu=$single_line[4]; $tests=$single_line[5]; sub write_data { my($operation,$seconds,$usr,$sys,$cpu,$tests) = @_; $count = 0; $count += $dbh->do ("INSERT INTO main (operations,seconds,usr,sys,cpu, +tests) VALUES($operation,$seconds,$usr,$sys,$cpu,$tests)

In reply to Trying to process some text... by japhySnyder

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.