in reply to Unique Data Formatting

...I want to prefix the Summary data line with the job name.
I think part of the problem is
print $_, "\n$job: ";
where $job is printed on the line following the current line. Better to remember the previous lines job and print it if needed.

The following might help get you started.

#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Indent = 1; my ($job); while(<DATA>){ chomp; next unless /Synchronizing started|Synchronizing finished|Summary/; my $summary; $summary++ if /Summary/; my $this_job; if (($this_job) = $_ =~ /"New Job (\d+)"$/){ $job = $this_job; } print qq{job: $job } if $summary; print qq{$_\n}; }; __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.
outputs
[4/14/2008 4:45 PM] Synchronizing started, job: "New Job 1" [4/14/2008 4:45 PM] Synchronizing finished, job: "New Job 1" job: 1 [4/14/2008 4:45 PM] Summary: Files processed: 6,554; Files copi +ed: 1; Bytes processed: 1,633,599,552; Bytes copied: 1,221,120. [4/14/2008 5:06 PM] Synchronizing finished, job: "New Job 2" job: 2 [4/14/2008 5:06 PM] Summary: Files processed: 136; Files copied +: 58; Bytes processed: 14,427,075; Bytes copied: 14,427,075. [4/14/2008 5:08 PM] Synchronizing started, job: "New Job 3" [4/14/2008 5:08 PM] Synchronizing finished, job: "New Job 3" job: 3 [4/14/2008 5:08 PM] Summary: Files processed: 38; Files copied: + 17; Bytes processed: 292,097; Bytes copied: 294,793.
Not sure what you are trying to do with the rest of the code.

Replies are listed 'Best First'.
Re^2: Unique Data Formatting
by raj8 (Sexton) on Apr 18, 2008 at 16:43 UTC

    Thanks, but I still get an incorrect job associated with the Summary data. When a job Finishes, I need that line and I need to associate that with the Summary line. For the most part it works, but in some instances I still get a wrong job ID associated with the Summary line as shown below with Job 3 and Job 1.

    [4/17/2008 11:03 PM] Synchronizing started, job: "Job 1" [4/17/2008 11:03 PM] Synchronizing finished, job: "Job 1" job: 3 [4/17/2008 11:03 PM] Summary: Files processed: 6,566; Files cop +ied: 0; Bytes processed: 1,633,707,954; Bytes copied: 0.
Re^2: Unique Data Formatting
by raj8 (Sexton) on Apr 18, 2008 at 18:52 UTC

    Thanks for your help, but just an update. It must have been a bad log file that I might have cut data out of it causing the response. However, the code section below doesn't account for any Job Name such as a Job Named 'My files' or 'My files 001'. I would want to capture the job name that is after the colon that could be any character, sets of characters or numbers such as:

    [4/14/2008 4:45 PM] Synchronizing started, job: "My Files 01" [4/14/2008 4:45 PM] Synchronizing finished, job: "My Files 01" job: My Files 01 [4/14/2008 4:45 PM] Summary: Files processed: 6,554; +Files copied [4/14/2008 4:45 PM] Synchronizing started, job: "New Job 1" [4/14/2008 4:45 PM] Synchronizing finished, job: "New Job 1"
      ...capture the job name that is after the colon that could be any character, sets of characters or numbers...
      But is the job name between the quotes? Include the quotes? Always at the end of the string? Is there a space after the colon, is that part of the name?

      Have a gander at the tutorials: perlrequick and perlretut. The perlre doc has the full low down.

      Adjust the following to suite.

      my ($job) = $str =~ / job : # "...the colon..." \s " # opening quote ( # start capture [^"]+ # one or more of anything that isn't a quote ) # end of capture " # closing quote $ # at the end of the string /x;