Yet another way...
use strict; use Data::Dumper; my $i = 0; my %records; while(<DATA>){ my($key, $val); if (/^$/){ #end of record $i++; next; } ($key, $val) = ($1, $2) if /(\w+)\s+:.(\d+) /; ($key, $val) = ($1, $2) if /(\w+)\s+:.>(.*)</; ($key, $val) = ($1, $2) if /(\w+)\s+:.'(.*)'/; $records{$i}{$key}=$val; } print Data::Dumper->Dump([\%records],[qw/records/]); __DATA__ Name : >Mick< [Mick] IC : '91919191929' [9191919129] PC : 123 [123] Number : >1960132400000< [1960132400000] Location : >000e 0036< [000e 0036] extension : >< Capability : >"CARES< ["CARES] Info : >6005494c523142< [6005494c523142] Name : >Nick< [Nick] IC : '1235467000' [1235467000] PC : 124 [124] Number : >1960192500000< [1960192500000] Location : >000f 0034< [000f 0034] extension : >< Capability : >< Info : >< Name : >Nick< [Nick] IC : '1235467000' [1235467000] PC : 124 [124] Number : >< [00] Location : >000f 0034< [000f 0034] extension : >< Capability : >.< Info : ><

OUTPUT:
$records = { '1' => { 'Capability' => '', 'extension' => '', 'PC' => '124', 'Number' => '1960192500000', 'IC' => '1235467000', 'Info' => '', 'Location' => '000f 0034', 'Name' => 'Nick' }, '0' => { 'Capability' => '"CARES', 'extension' => '', 'PC' => '123', 'Number' => '1960132400000', 'IC' => '91919191929', 'Info' => '6005494c523142', 'Location' => '000e 0036', 'Name' => 'Mick' }, '2' => { 'Capability' => '.', 'extension' => '', 'PC' => '124', 'Number' => '', 'IC' => '1235467000', 'Info' => '', 'Location' => '000f 0034', 'Name' => 'Nick' } };

This is a hoh, just as easily could be a AoH's...
JamesNC

In reply to Re: Can't read files content by JamesNC
in thread Can't read files content by bh_perl

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.