Showing code is a good idea but as I was bored at the time this should get you started:

use Data::Dumper; # get you datafile into a scalar variable (sample put in __DATA__) my $data = join '', <DATA>; my $split_pat = qr/-{28}\n([\w\d\.-]+)\n-{28}\n*/; my @data = split /$split_pat/, $data; shift @data; %servers = @data; for my $server (keys %servers) { my %progs = split /\n{2,}/, $servers{$server}; $servers{$server} = \%progs; for my $prog ( keys %{$servers{$server}} ) { my @data = split /\n+/, $servers{$server}->{$prog}; $servers{$server}->{$prog} = \@data; } } print Dumper \%servers; __DATA__ Dumper output: $VAR1 = { 'Server1.dom.com' => { 'WINDOWS 2000 SERVER SP2' => [ 'WARNI +NG MS01-022 Q296441', 'Patch + NOT Found MS02-001 Q311401', 'Patch + NOT Found MS02-006 Q314147', 'Patch + NOT Found MS02-012 Q313450', 'Patch + NOT Found MS02-013 Q300845', 'Patch + NOT Found MS02-014 Q313829' ], 'Internet Information Services 5.0' = +> [ + 'Patch NOT Found MS02-001 Q311401', + 'Patch NOT Found MS02-012 Q313450' + ], 'Internet Explorer 5.5 SP2' => [ 'Pat +ch NOT Found MS02-005 Q316059', 'Pat +ch NOT Found MS02-009 Q318089' ] }, 'Server2.dom.com' => { 'WINDOWS 2000 SERVER SP2' => [ 'WARNI +NG MS01-022 Q296441', 'Patch + NOT Found MS02-001 Q311401', 'Patch + NOT Found MS02-006 Q314147', 'Patch + NOT Found MS02-013 Q300845', 'Patch + NOT Found MS02-014 Q313829' ], 'Internet Explorer 5.5 SP1' => [ 'Pat +ch NOT Found MS02-005 Q316059', 'Pat +ch NOT Found MS02-009 Q318089' ] } };

Effort in reply is proportional to effort exerted by seeker of wisdom.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Tricky File Parsing by tachyon
in thread Tricky File Parsing by dnickel

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.