Hi John,

I received your code.   Thanks.
I would like to know how to check the values of the keys in the hash.  I
checked the Perl cookbook and It showed me how to get the key value pairs
and print them, but I am not familiar with populating an array with a hash,
or how to
dynamically print the values out.

Please help.
Thanks


----------------------------------------------------------  I

my $file = 'artb30_short.da4';
open INFILE, $file or die "Can't open $file: $!";

my @order_detail;
while ( <INFILE> ) {
    last if /^GROUP TOTALS/;
    s/\s+\Z//;                  # remove all trailing whitespace
    next unless /\d\.\d\d\Z/;   # only want lines with dollar amounts at end
    my %item;
    if ( length() < 120 ) {     # item 1 lines are shorter
        @item{ qw/cust_number cust_name cycle customer_type acct_contact
phone credit_limit/ } =
            map { s/^\s+//; $_ }
            unpack 'A6 x2 A30 x2 A5 x2 A15 x2 A20 x2 A15 x2 A*', $_;
# unpack'A' removes trailing whitespace so we need the map{}
# to remove leading whitespace
        }
    elsif ( /^\d/ ) {           # item 2 lines start with a digit
        @item{ qw/inv_no type inv_date current days_1_30 days_31_60
                days_61_90 days_over_90 on_hold unap_cash total_ar/ } =
            map { s/^\s+//; $_ }
            unpack 'A6 x A3 x A8' . 'x3 A11' x 8, $_;
        }
    else {                      # item 3 lines
        @item{ qw/cust_totals_current cust_totals_days_1_30
cust_totals_days_31_60
                cust_totals_days_61_90 cust_totals_days_over_90
cust_totals_on_hold
                cust_totals_unap_cash cust_totals_total_ar/ } =
            map { s/^\s+//; $_ }
            unpack 'x19' . 'x3 A11' x 8, $_;
        }
    push @order_detail, \%item;


    }



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to