Hello

I was trying this script
#! perl -slw use strict; open DATA, "test2.txt" or die "Cant open file"; print "Receiptno. Consumer name Consumer no. Subdivision + Type of work Phase Cheque no. Amount"; printf "%-11s %-23s %-12s %-14s %-16s %-10s %-11s %-14.2f\n", m[ ( [0-9\.]+ )\s+ ( \S+ (?: \s \S+ )? ) \s+ ( [0-9\.]+ )\s+ ( \S+ (?: \s \S+ )? ) \s+ ( \S+ (?: \s \S+ )? ) \s+ ( \S+ (?: \s \S+ )? ) \s+ ( [0-9\.]+ ) \s+ ( \S+ (?: \s \S+ )? ) \s+ ]x while <DATA>;
with this set of data
127 Stella Somethinglong 2345 Petersburg New service Single + 23456 1330.00 128 Sandra 4567 Elm Street Replacement Three 23445 4800 +.00 129 Tessa Barry 2345 Bakersville New service Single 37456 + 1330.00
The third record does not display in the output. Why is that so?

Also how can we calculate the total of the last column (amount column)?

perl_seeker

In reply to Re^8: Text file processing question by perl_seeker
in thread Text file processing question by perl_seeker

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.