in reply to Re^3: Sorting Data?
in thread Sorting Data?

YES! This is perfect! =) Thank you so much. Can you explain (briefly) how the code works? I'd like to understand a little bit better what "magic" it is doing..

Replies are listed 'Best First'.
Re^5: Sorting Data?
by AnomalousMonk (Archbishop) on Mar 31, 2017 at 14:48 UTC
    Can you explain ...? I'd like to understand a little bit better ...

    You can gain insight yourself into the operation of this (or any) program by inserting print/dump statements at strategic points to see how data is extracted and transformed and how structures are built up:

    use Data::Dumper; ... my %keys; while(<DATA>) { push @secondpass, $_; $keys{$_}++ for /SATID (\d\d)/g; } print Dumper \%keys; my @keyorder = sort keys %keys; print Dumper \@keyorder; for (@secondpass) { my %items = reverse /(SATID (\d\d).{27})/g; print Dumper \%items; <STDIN>; print join ' ', map { $items{$_} // ' ' x 35 } @keyorder; } ...
    The  <STDIN>; after the print statement in
        print Dumper \%items;  <STDIN>;
    in the for-loop just pauses output until you hit Enter so you are not overwhelmed by stuff. (NB: My personal favorite structured data dumper is Data::Dump, but Data::Dumper is core. :)


    Give a man a fish:  <%-{-{-{-<