I am new to work hash tables in perl,Can some one please help me how to get the hash values and keys in same sequence while getting hash from sub routinue.
sub Msg { my $line = shift; my ($pf,$fixFields) = split(/received:|Sent:/, $line); %fixMsg; %fixMsg = split(/[,=]/, $fixFields); @fixMsg{('_time_', '_mi_', '_fixsession_')} = (split(/\|/, $pf))[2 +,3,5]; return \%fixMsg; } open file,"abc.txt" while(<file>){ $msg=pfUtils::Msg($_); foreach my $key (%{$msg}) { if (!($key eq _mi_|$key eq _fixsession_|$key eq _time_ +|$msg->{$key} eq '')) { printf "\n\t%20s (%3d) = %s ", $code,$key,$value; } } } close file;
"abc.txt" File contains informationa as below
^|server |13:20:52.423762|pht0211j-hello|DebugLow|NAQ|PXXXX thread +started. Thread ID=-1349444688.|<> ^|Server |13:20:52.425505|pht0211j-hello|DebugLow|Sian01|Sian01 Sen +t: 8=FIX.4.2,9=65,35=A,34=1,49=FBCO20,56=CMS,52=20080111-18:20:52,43= +N,98=0,108=60,10=133|<> ^|Server |13:20:52.425602|pht0211j-hello|InfoGeneral|Sian01|SiacCon +n001 Logon : 8=FIX.4.2,9=65,35=A,34=1,49=FBCO20,56=CMS,52=20080111-18 +:20:52, 43=N,98=0,108=60,10=133|<> ^|server |13:20:52.647996|pht0211j-hello|InfoGeneral|abc|Starting A +BC link: Abxxx|<>

In reply to Hash accessing issue while returning hash from sub routinue by tilak_sai

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.