Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re: Accessing or printing key and value by 2teez
in thread 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found