Hi Monks,

I have come to a rock solid stop on this. I am attempting to gather data on files that I am syncing on my pc which I call jobs. For each job, I want to gather:

1.) Unique Date and Time for Analyzing

2.) Unique Date and Time for Sync to Start

3.) Unique Date and Time for Synchronizing Finished

4.) Unique Date and Time for Summary of each job.

As shown, the Summary line does not contain the job name. Therefore, I want to prefix the Summary data line with the job name. The problem I am having is that when I run the script it sometimes it prefixes an incorrect 'job' name on lines that do not belong to that particular job. I would hope that once I get this corrected, I could enter this data in a small mysql db for better reporting later. Anyway, thanks for your time and any suggestions that will help me overcome this battle.

use strict; my @today = get_cur_time(); ### Compensates for old data if needed ### #$today[1]--; ### Defining Jobs ### my @jobs = ("Job 3"); ### Defining Print Header ### print "\n======================================\n"; print "\n Today: @today\n"; print "\n======================================\n\n"; ### Opening Log File ### open(FH1,"c:\\default.log") || die "Cannot open file:$!\n"; ### keep Log open while reading ### GETDATA:while(<FH1>){ ### If not find..Carry on ### next unless /Synchronizing started|Synchronizing finished|Summary/; my @date= m|(\d+)/(\d+)/(\d+)|; for my $i(0..$#today) { next GETDATA if $date[$i]!=$today[$i]; } foreach my $job (@jobs) { my $syncStartD = substr($_,1,9); my $syncStartT = substr($_,11,7); my $syncStartjobName = substr($_,20,120); my $filesProcessed = substr($_,21,44); print $_, "\n$job: "; }; }; ### Subroutines ### sub get_cur_time { my ($Day, $Month, $Year) = (localtime(time))[3..6]; $Year += 1900; #--Note - the "sprintf"s are no longer necessary ... $Month = sprintf '%02d', $Month + 1; $Day = sprintf '%02d', $Day; return ($Month,$Day,$Year); }; __DATA__ [4/14/2008 4:44 PM] Analyzing started, job: "New Job 1" [4/14/2008 4:45 PM] Synchronizing started, job: "New Job 1" [4/14/2008 4:45 PM] Analyzing finished, job: "New Job 1" [4/14/2008 4:45 PM] Synchronizing finished, job: "New Job 1" [4/14/2008 4:45 PM] Summary: Files processed: 6,554; Files copied: 1; +Bytes processed: 1,633,599,552; Bytes copied: 1,221,120. [4/14/2008 5:03 PM] Analyzing started, job: "New Job 2" [4/14/2008 5:06 PM] Analyzing finished, job: "New Job 2" [4/14/2008 5:06 PM] Synchronizing finished, job: "New Job 2" [4/14/2008 5:06 PM] Summary: Files processed: 136; Files copied: 58; B +ytes processed: 14,427,075; Bytes copied: 14,427,075. [4/14/2008 5:08 PM] Analyzing started, job: "New Job 3" [4/14/2008 5:08 PM] Analyzing finished, job: "New Job 3" [4/14/2008 5:08 PM] Synchronizing started, job: "New Job 3" [4/14/2008 5:08 PM] Synchronizing finished, job: "New Job 3" [4/14/2008 5:08 PM] Summary: Files processed: 38; Files copied: 17; By +tes processed: 292,097; Bytes copied: 294,793.

In reply to Unique Data Formatting by raj8

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.