Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Accessing or printing key and value

by 2teez (Vicar)
on Dec 11, 2012 at 01:22 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-20 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found