blink has asked for the wisdom of the Perl Monks concerning the following question:
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:
If I ran this program in it's completed state today (Monday), it would return:
#!/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?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Positional Pattern-Matching
by BrowserUk (Patriarch) on Sep 24, 2002 at 02:13 UTC | |
Re: Positional Pattern-Matching
by PodMaster (Abbot) on Sep 24, 2002 at 02:02 UTC | |
(Kozz) Parse into hash of hashrefs
by Kozz (Friar) on Sep 24, 2002 at 02:57 UTC |
Back to
Seekers of Perl Wisdom