I'm having a hard time with this script. It needs to print the "Daily Window", unless the "Daily Window" is "00:00:00 - 24:00:00".

When run, the output of the code below is:

corpsrv2_archives runs on Monday 00:00:00 --> Monday 06:00:00 Tuesday 00:00:00 --> Tuesday 06:00:00 Wednesday 00:00:00 --> Wednesday 06:00:00 Thursday 00:00:00 --> Thursday 06:00:00 Friday 00:00:00 --> Friday 06:00:00 Saturday 00:00:00 --> Saturday 06:00:00 corpsrv2_finp_cold runs on Monday 00:00:00 --> Monday 06:00:00 Tuesday 00:00:00 --> Tuesday 06:00:00 Wednesday 00:00:00 --> Wednesday 06:00:00 Thursday 00:00:00 --> Thursday 06:00:00 Friday 00:00:00 --> Friday 06:00:00 Saturday 00:00:00 --> Saturday 06:00:00 corpsrv2_psoft_hot runs on Monday 00:00:00 --> Monday 06:00:00 Tuesday 00:00:00 --> Tuesday 06:00:00 Wednesday 00:00:00 --> Wednesday 06:00:00 Thursday 00:00:00 --> Thursday 06:00:00 Friday 00:00:00 --> Friday 06:00:00 Saturday 00:00:00 --> Saturday 06:00:00
Can anyone help me to sort out what I'm missing, here?
#!/usr/local/bin/perl -w use strict; my %data; my $sid; my $day; while (<DATA>) { next if (/Default/); if (/Policy Name:(\s+)(.*?)$/) { $sid = "$2"; next; } next unless (/(\s+)Daily Windows\:/ .. /(\s+)Schedule\:/); if (/(^\s+)(.*?day)/) { next if (/24|Week/); $day = $_; chomp $day; push @{$data{$sid}}, $day; } } foreach my $key (sort keys %data) { print "$key runs on\n"; foreach (@{$data{$sid}}) { print "$_\n"; } }
__DATA__ ------------------------------------------------------------ Policy Name: corpsrv2_archives Schedule: Full Type: Full Backup Maximum MPX: 1 Retention Level: 3 (1 month) Number Copies: 1 Fail on Error: 0 Residence: (specific storage unit not required) Volume Pool: (same as policy volume pool) Calendar sched: Enabled Thursday, Week 1 Friday, Week 1 Saturday, Week 1 Thursday, Week 2 Friday, Week 2 Saturday, Week 2 Thursday, Week 3 Friday, Week 3 Saturday, Week 3 Thursday, Week 4 Friday, Week 4 Saturday, Week 4 Thursday, Week 5 Friday, Week 5 Saturday, Week 5 Daily Windows: Sunday 06:20:00 --> Sunday 07:20:00 Monday 06:20:00 --> Monday 07:20:00 Tuesday 06:20:00 --> Tuesday 07:20:00 Wednesday 06:20:00 --> Wednesday 07:20:00 Thursday 06:20:00 --> Thursday 07:20:00 Friday 06:20:00 --> Friday 07:20:00 Saturday 06:20:00 --> Saturday 07:20:00 ------------------------------------------------------------ Policy Name: corpsrv2_finp_cold Schedule: corpsrv2_finp_cold Type: Automatic Full Backup Maximum MPX: 2 Retention Level: 3 (1 month) Number Copies: 1 Fail on Error: 0 Residence: (specific storage unit not required) Volume Pool: (same as policy volume pool) Calendar sched: Enabled Sunday, Week 1 Saturday, Week 1 Sunday, Week 2 Saturday, Week 2 Sunday, Week 3 Saturday, Week 3 Sunday, Week 4 Saturday, Week 4 Sunday, Week 5 Saturday, Week 5 Daily Windows: Saturday 22:00:00 --> Sunday 04:00:00 Schedule: Default-Application-Backup Type: Application Backup Maximum MPX: 2 Retention Level: 3 (1 month) Number Copies: 1 Fail on Error: 0 Residence: (specific storage unit not required) Volume Pool: (same as policy volume pool) Daily Windows: Sunday 00:00:00 --> Sunday 24:00:00 Monday 00:00:00 --> Monday 24:00:00 Tuesday 00:00:00 --> Tuesday 24:00:00 Wednesday 00:00:00 --> Wednesday 24:00:00 Thursday 00: Policy Name: corpsrv2_psoft_hot Schedule: corpsrv2_psoft_hot Type: Automatic Full Backup Maximum MPX: 2 Retention Level: 3 (1 month) Number Copies: 1 Fail on Error: 0 Residence: (specific storage unit not required) Volume Pool: (same as policy volume pool) Calendar sched: Enabled Friday, Week 1 Saturday, Week 1 Friday, Week 2 Saturday, Week 2 Friday, Week 3 Saturday, Week 3 Friday, Week 4 Saturday, Week 4 Friday, Week 5 Saturday, Week 5 Daily Windows: Monday 00:00:00 --> Monday 06:00:00 Tuesday 00:00:00 --> Tuesday 06:00:00 Wednesday 00:00:00 --> Wednesday 06:00:00 Thursday 00:00:00 --> Thursday 06:00:00 Friday 00:00:00 --> Friday 06:00:00 Saturday 00:00:00 --> Saturday 06:00:00 Schedule: Default-Application-Backup Type: Application Backup Maximum MPX: 2 Retention Level: 3 (1 month) Number Copies: 1 Fail on Error: 0 Residence: (specific storage unit not required) Volume Pool: (same as policy volume pool) Daily Windows: Sunday 00:00:00 --> Sunday 24:00:00 Monday 00:00:00 --> Monday 24:00:00 Tuesday 00:00:00 --> Tuesday 24:00:00 Wednesday 00:00:00 --> Wednesday 24:00:00 Thursday 00:00:00 --> Thursday 24:00:00 Friday 00:00:00 --> Friday 24:00:00 Saturday 00:00:00 --> Saturday 24:00:00

Edit by tye, add READMORE, missing >


In reply to Matching lines between several other lines by blink

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.