You might wanna look into Parse::RecDescent. Anyway, something like this you ought to be able to do
#!/usr/bin/perl use strict; use Data::Dumper; eval q{use warnings;} or local $^W=1; my @SSS = (); OUTER: while (my $line = <DATA>) { chomp $line; if( @SSS ){ if( $line =~ /Daily Windows:/i ) { while($line = <DATA>) { if ($line =~ /schedule:\s+(\S+)/i){ push @SSS, { 'Schedule' => $1 }; next OUTER; }elsif($line =~/\w+\s+\d\d\:\d\d\:/){ my( $fDay, $fTime, $tDay, $tTime ) = grep/$_/,spli +t /\s+|-->/,$line; push @{$SSS[-1]->{ 'Windows' }}, [ $fDay, $fTime, $tDay, $tTime ]; } } }else{ my($a,$b) = split /\:/, $line, 2; $SSS[-1]->{ $a } = $b; } }elsif($line =~ /schedule:\s+(\S+)/i) { push @SSS, { 'Schedule' => $1 }; } } print Dumper \@SSS; __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

$VAR1 = [
          {
            '   Volume Pool' => '     (same as class volume pool)',
            '   Type' => '            Full Backup',
            '   Residence' => '       (specific storage unit not required)',
            'Windows' => [
                           [
                             'Saturday',
                             '02:00:00',
                             'Saturday',
                             '12:00:00'
                           ]
                         ],
            '   Retention Level' => ' 2 (5 weeks)',
            'Schedule' => 'Full',
            '   Maximum MPX' => '     1',
            '   Frequency' => '       every 1 day'
          },
          {
            '   Volume Pool' => '     (same as class volume pool)',
            '   Type' => '            Cumulative Incremental Backup',
            '   Residence' => '       (specific storage unit not required)',
            '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'
                           ]
                         ],
            '   Retention Level' => ' 2 (5 weeks)',
            'Schedule' => 'CINC',
            '   Maximum MPX' => '     1',
            '   Frequency' => '       every 1 day'
          }
        ];
I would guess "positional pattern matching" would somehow involve \G and pos, but that's just me (i'd call this simply parsing).

____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: Positional Pattern-Matching by PodMaster
in thread 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.