I was just trying to have people to bounce some ideas off of - however this is what I came up with - its crude and runs slow on large files (the 1 file I am running this off of as a test is 80,000+ lines long) - If someone sees something I can do differently I am open to suggestions

#!/usr/bin/perl use strict; use warnings; no warnings 'uninitialized'; use Data::Dumper; use Tie::File; my $base = $ARGV[0]; open(FILE, $base) || die "Unable to locate file: $!\n"; my (@searray,@flarray); tie(@flarray, 'Tie::File',$base); while(<FILE>) { my ($start,$end); chomp; if($_ =~ /-El\s+vg/../vgserial_id/) { $start = (split /\s+/,$_)[3] if($_ =~/-El/); $end = (split /\s+/, $_)[1] if($_ =~/vgserial_id/); } if(defined $start) { push(@searray, $start); } else { $start = ''; +} if(defined $end) { push(@searray, $end); } else { $end = ''; } } my %hash_ref = @searray; #print Dumper \%hash_ref; foreach my $hkey(keys %hash_ref) { my $hvalue = $hash_ref{$hkey}; my $count = 0; for (my $i = 0; $i < @flarray; $i++) { next unless $flarray[$i] =~ /$hvalue/; next if($flarray[$i] =~ /vgserial_id/); my ($mc,$lvsip) = (($i-1),($i-5)); my $mount = (split /\s+/, $flarray[$mc])[1]; my $lvnam = (split /\s+/, $flarray[$lvsip])[3]; next if($mount =~ /None/); print "$i: VG: $hkey : MOUNT: $mount : LV_name: $lvnam : SIZE: $ +size\n"; } }

In reply to Re: Parsing a Large file with no reason by mrras25
in thread Parsing a Large file with no reason by mrras25

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.