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?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|