raj8 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I put this out earlier, but how would you gather a job name as shown below that is not called 'New Job'? Basically, I want to capture any type of name that I give a job i.e. Testing01, mymusic, myimages2 etc. Could I use a character class here? As always, thanks for your time and I welcome your wisdom.
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Character Class?
by Narveson (Chaplain) on Apr 19, 2008 at 05:34 UTC | |
|
Re: Regex Character Class?
by wfsp (Abbot) on Apr 19, 2008 at 06:14 UTC | |
|
Re: Regex Character Class?
by apl (Monsignor) on Apr 19, 2008 at 11:48 UTC |