Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Accessing or printing key and value

by 2teez (Priest)
on Dec 11, 2012 at 01:22 UTC ( #1008204=note: print w/ replies, xml ) Need Help??


in reply to Accessing or printing key and value

Hi sfrisch@mt.gov.
Please, I might be wrong here, but I don't see any "correlation" between the first part of your code and the input given.
However, the second part staring from this line:

# MOVe to running against the new file made sumery.txt open FILE2,"sumfile.txt"; ...
Suggested to me that the "input" given here should be data in your sumfile.txt file. To which you needed to sort.
If the above is correct and this "Out put is the same only sorted that is what I am shooting for.".

I think a Schwartzian Transform could work for you like so:
#!/usr/bin/perl use warnings; use strict; my @data_array; while (<DATA>) { chomp; next if $_ eq ''; push @data_array, $_; } print map { $_->[0], $/ } sort { $a->[1] <=> $b->[1] } map { /.+?([0-9]+?)\s/; [ $_, $1 ] } @data_array; __DATA__ 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
Output:
DOABIL309 EXE-SOS-3201_DFLT Ora DOABIL3020 ITSD-ENT_OP-DMSB-DIDS 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
I sorted using the first column.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: Accessing or printing key and value
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-08-23 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (176 votes), past polls