Ok heres what I updated it to.

#!/usr/bin/perl use DBI; use File::Tail; use POSIX(); our $bWin; BEGIN { $bWin = ($^O eq "MSWin32") ? 1 : 0; } Loop(); sub Loop { print "Updating Server Log -> DB\n"; Update_DB_Actions(); } sub Update_DB_Actions { my $dbh = DBI->connect('DBI:mysql:database=arma3;host=localhost',' +root','root') || die "Could not connect to database: $DBI::errstr"; my $filename = POSIX::strftime('ServerLog(%m-%d-%Y).log', localtim +e ); my $log = "D:\\ServerTools\\Logs\\$filename"; my $qu_re1 = q{(.?) started server @ (\d+):(\d+):(\d+)}; my $qu_re2 = q{(.?) restarted server @ (\d+):(\d+):(\d+)}; my $qu_re3 = q{(.?) stopped server @ (\d+):(\d+):(\d+)}; my $file = File::Tail->new(name=>$log); while(defined($line=$log->read)) { my $sql = "INSERT INTO `actions` (log) VALUES (?)"; $insa = $dbh->prepare($sql) or die $!; if($line =~ /$qu_re1/i || /$qu_re2/i || /$qu_re3/i) { $insa->execute($line); print "Inserted Action!\n"; } } unlink $log; }

But now I get a new error.

Can't locate object method "read" via package "D:\ServerTools\Logs\Ser +verLog(07- 06-2013).log" (perhaps you forgot to load "D:\ServerTools\Logs\ServerL +og(07-06-2 013).log"?) at script.pl line 112.


In reply to Re^2: Help w/ regex in filename by dcthehole
in thread Help w/ regex in filename by dcthehole

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.