Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I am trying to print the keys and the values of a hash of array using a data structure. I would like to it sorted by key.<\p>

I have got the array set up at least I think I do I have all kinds of print statments telling me that I am not too crazy. I would like to have a print out that looks like the following only soted by the second -- or first fields.

Input

DOABIL3020 ITSD-ENT_OP-DMSB-DIDS Ora

DOABIL309 EXE-SOS-3201_DFLT Ora

DOABIL3400 ITSD-ENT_OP-ETSB-MID PRD

DOABIL5310 ITSD-ENT_OP-ETSB-MID TST

DOABIL6230 EXE-SOS-3201_DFLT PRD

DOABIL7001 ITSD-ENT_OP-ETSB-EAS PRD

DOABIL7005 ITSD-ENT_OP-AIMB-DCSEC PRD

DOABIL7006 ITSD-ENT_OP-AIMB-DCSEC PRD

DOABIL7504 EXE-SOS-3201_DFLT PRD

DOABIL7581 ITSD-ENT_OP-NTSB-NET PRD

DOABIL7582 ITSD-ENT_OP-NTSB-NET PRD

DOABIL7583 ITSD-ENT_OP-NTSB-NET PRD

Out put is the same only sorted that is what I am shooting for.

open INTO,">sumfile.txt"; open FILE, "serverinventory.txt"; while(<FILE>){ chomp; $_ =~ s/\"//g; #$_=~ s/\,/ /g; @LINE=split(/\,/); $HOST=$LINE[1]; if($HOST =~/DOAISDBLADE/|| $HOST =~ /DOAISD9/|| $HOST =~/K +VM/|| $HOST =~/DOABILBLA/){ } elsif($LINE[19] =~ /EXE/||$LINE[19] =~ /ITSD/||$LINE[19] = +~/REV/){ $FMM = $LINE[19]; $USE = $LINE[16]; $HOST = $LINE[1]; my $USE = substr($USE,0,3); my $AG = substr($LINE[16],4,17); #printf INTO ("%0s %0s\n",$FMM,$HOST,$USE); print INTO "$HOST $FMM $USE\n"; } } close FILE; close INTO; # MOVe to running against the new file made sumery.txt open FILE2,"sumfile.txt"; open too,">out.txt"; # open file for counts to be depposited to while(<FILE2>){ chomp; @arry1 = split(/ /); $TOTAL = $tab1=$arry1[0]; $tab2=$arry1[1]; #print "$tab1 $tab2\n"; push(@ {$ARG{"$tab1"}},"$tab2"); } # foreach $string (keys %ARG) { #HASH OF ARRAY SORTED $last = $#{$ARG{$string}}; #GETS THE COUNT OF THE JOBS FOR +EACH TABLE $last=$last + 1; print "$string $ARG{$string}\n"; }

I get a print of the keys but not the value. So I do not understand how to get to all tyhe data I am generating.<\p>


In reply to Accessing or printing key and value by sfrisch@mt.gov

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (13)
    As of 2014-07-23 12:28 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (141 votes), past polls