...I want to prefix the Summary data line with the job name.I think part of the problem is
where $job is printed on the line following the current line. Better to remember the previous lines job and print it if needed.print $_, "\n$job: ";
The following might help get you started.
outputs#!/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.
Not sure what you are trying to do with the rest of the code.[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.
In reply to Re: Unique Data Formatting
by wfsp
in thread Unique Data Formatting
by raj8
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |