Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The reason I am going to try spliting the script across 2 machines is because I was thinking the same thing as Perlbotics above. There is just too much load on the resources if I try to do everything at the same time. By splitting the global task in 2 parts I can either run both concurrently on 2 machines or in sequence on 1, depending on my time constraints.

But just in case, here is the rest of the code you were asking for. Am I doing something horribly wrong there that is causing needless load on the CPU?

The Load data function just executes this sql:
my $sql = qq{ LOAD DATA LOCAL INFILE \"$mysql_tmp_filename\" INTO TABLE `$tblname` FIELDS TERMINATED BY ',' OPTIONALLY enclosed by '\"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\r\\n' IGNORE 3 LINES (file_name,\@file_p,file_size,\@file_la,\@file_lc,\@file_c, file_exten +sion) set file_last_access = STR_TO_DATE(\@file_la, '%c/%e/%Y %l:%i %p'), file_path = \@file_p, file_share_name = substring_index(substring_index(\@file_p,'\\\\',3),' +\\\\',-1), file_last_change = STR_TO_DATE(\@file_lc, '%c/%e/%Y %l:%i %p'), file_creation = STR_TO_DATE(\@file_c, '%c/%e/%Y %l:%i %p') }; my $sth = $dbh->prepare($sql); $sth->execute();
and here is fix_file_4mysql:
sub fix_file_4mysql { #arguments: 1) path to file #returns: 1) the filename fixed for use in a mysql query #fix the contents of the temp file for use in mysql my $tmp_filename = shift; open( IN, "+<$tmp_filename" ); my @file = <IN>; seek IN, 0, 0; foreach my $file (@file) { $file =~ s/\\/\\\\/g; print IN $file; } close IN; #fix temp_filename for use in mysql my $mysql_tmp_filename = $tmp_filename; $mysql_tmp_filename =~ s/\\/\\\\/g; return $mysql_tmp_filename; }

In reply to Re^3: Multithreaded Script CPU Usage by Zenshai
in thread Multithreaded Script CPU Usage by Zenshai

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [holli]: Can somebody identify this connector?

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (4)
    As of 2017-11-19 14:13 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (281 votes). Check out past polls.