Sorry that I could not post the whole code

Here is the thing I've tried out.

Problem is that I'm unable to match the Numbers inside the data. Please suggest the best way to do this

#!/usr/bin/perl use strict; # Array to hold the text file data my @chunks; open(CONF, $txtFile) || die "cannot find the text file\n"; while(<CONF>){ chomp; if (/^#/){ # Must be a comment, skip it next; } elsif (/^\s*$/) { # Only contains whitespace, skip it # could be blank lines next; } elsif (/^M/){ # Contains dos/mac control characters my @lines = split /^M/, $_; for ( my $i = 0 ; $i <= $#lines ; $i++ ){ push(@chunks, $lines[$i]); } } else { # assumed to be a normal data line # trim trailing and leading spaces for parsing the data later $_ =~ s/^\s+|\s+$//g; push(@chunks, $_); } #print "Found data for ", scalar(@chunks), " lines in $csv\n\n"; } close(CONF); # Get the Array Index where the 'Summary of This Bill Period Charges' +text is located my $index = indexArray('Summary of This Bill Period Charges', @chunks) +; # skip next 4 lines $index = $index + 4; foreach ( $index .. @chunks ) { if ( $data =~m/(\d+)\s{2,}(\d+)\s{2,}((\d|-)?(\d|,)*\.?\d*)\s{2,}( +(\d|-)?(\d|,)*\.?\d*)\s{2,}/ ) { print $5; } } # Thanks to a post which gave me this snippet sub indexArray{ my ($text, @data) = @_; for( 1..@data ) { ; if ( $data[$_] =~ m/$text/ig ) { ; return $_-1; } } -1 }

In reply to Re^4: parsing text file by doubledecker
in thread parsing text file by doubledecker

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.