What I'd like this code-snippet to do, is match "Schedule: Full" or "Schedule: CINC" with whatever day of week/time is associated with that particular schedule. I've hacked something together, although not elegant, that will, at least, grab the first and second match of "Schedule:". For the life of me, I can't figure out how to grab the day of week and time. Here's the code:
#!/usr/local/bin/perl -w use strict; while (my $line = <DATA>) { chomp $line; my $count = 0 ; if ($line =~ /schedule:(\s+)(\w+)/gi){ my $count++; if ($count == 1){ my $first = $2; print "first one is $first\n"; } if ($count == 2){ my $second = $2; print "second one is $second\n" +; } } } __DATA__ Schedule: Full Type: Full Backup Frequency: every 1 day Retention Level: 2 (5 weeks) Maximum MPX: 1 Residence: (specific storage unit not required) Volume Pool: (same as class volume pool) Daily Windows: Saturday 02:00:00 --> Saturday 12:00:00 Schedule: CINC Type: Cumulative Incremental Backup Frequency: every 1 day Retention Level: 2 (5 weeks) Maximum MPX: 1 Residence: (specific storage unit not required) Volume Pool: (same as class volume pool) Daily Windows: Sunday 02:00:00 --> Sunday 12:00:00 Monday 02:00:00 --> Monday 12:00:00 Tuesday 02:00:00 --> Tuesday 12:00:00 Wednesday 02:00:00 --> Wednesday 12:00:00 Thursday 02:00:00 --> Thursday 12:00:00 Friday 02:00:00 --> Friday 12:00:00

If I ran this program in it's completed state today (Monday), it would return:

"Sunday 02:00:00"

I suppose that I could populate an array with "days of week" and test "today" against the data, but I cannot figure out logic which would be able to figure out whether or not "today" is schedule "Full" or schedule "CINC"

Anyone willing to help an SA, in need of a long vacation away from backups?


In reply to Positional Pattern-Matching 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.