#!/usr/bin/perl use Data::Dumper; use constant KEYS => qw/APP REG KPI INTERFACE DATE TIME NODE RAN SUCC_RATE/; use warnings; use strict; my @array; while (<DATA>) { my @line = split; my %hash; @hash{+KEYS} = @line; push @array, {%hash}; } print Dumper \@array; __DATA__ CORDR KZN MTC-N AINT 2011-09-29 09:00 DTL PM05 83.79 4 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA BR20 85.39 3 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA BR21 86.06 1 - - CORDR Unk MTC-N AINT 2011-09-29 09:00 JSA BR22 84.55 2 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA RN10 86.97 1 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA RS11 84.57 2 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA RS12 86.31 2 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA SD10 86.79 1 - - CORDR SGC MTC-N AINT 2011-09-29 09:00 JSA SN10 85.54 1 - -
To understand, read the following:
The strictures, according to Seuss
Data::Dumper
constant
perldata

In reply to Re: hash_reference from file by choroba
in thread hash_reference from file by hmadhi

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.