All, I managed to struggle through to get my desired output which is sorting on each array element inside its hash. See out output below. However my goal was/is to alert on any differences after the sort has executed. But I opted to use is_deeply w/no sort and this proved not to work due to how the OS created its v-devices even with manual in order creation. The way I have it now is a push, then I sort using the Schwartzian transform then I print. Is there a better way to push to @{$lsmap{...}} HoA while sorting? I hate to have to populate and sort separately. Thank you!

__CURRENT_DESIRED_OUT_:

0x00000010 => Available r2wpar_r1.610b24bfc20149ff17976c9c63f1a261 Available r2wpar_w1.2458bd43d1f3116046180e5e0e361ca7 0x0000001e => Available sapepp00_r1.2915b2239121c2eac69518efed0fbbe4 Available sapepp00_r2.88bdab9aa8334093e1bceaf393f8f88f Available sapepp00_e1.c330a9065d0c3243fe13016d5932c146 Available sapepp00_e2.7b1627b996222f9c74ab8393059788a9 Available sapepp00_p1.761becb64095de97b26e35d419ea2bcb 0x00000012 => Available sapepq00_r1.eacbba530a846f2e40315e892fb66532 Available sapepq00_r2.6d869942baf6fe277f2709fe604bea6d Available sapepq00_e1.0b6ed1a6d9bf9298d7465255b3ab33b4 Available sapepq00_e2.8e55566cd9b5fb35623cd958b4a317d4 Available sapepq00_p1.6beaabc01ab495cf83a138a1ba954d55 __END_OUT__ __RAW_INPUT__ SVSA Physloc Client Pa +rtition ID --------------- -------------------------------------------- --------- +--------- vhost43 U8284.22A.21AAF9V-V1-C33 0x0000000 +8 VTD vtscsi71 Status Available LUN 0x8100000000000000 Backing device twcsapsmmdb1_r1.5c3d6fbe5fa85c487f817a4ae464da0b Physloc Mirrored N/A VTD vtscsi94 Status Available LUN 0x8200000000000000 Backing device twcsapsmmdb1_s1.00dffa2880291e123ca1283ea3f26f2d Physloc Mirrored N/A SVSA Physloc Client Pa +rtition ID --------------- -------------------------------------------- --------- +--------- vhost9 U8284.22A.21AAF9V-V1-C16 0x0000001 +0 VTD vtscsi110 Status Available LUN 0x8100000000000000 Backing device r2wpar_r1.610b24bfc20149ff17976c9c63f1a261 Physloc Mirrored N/A VTD vtscsi111 Status Available LUN 0x8200000000000000 Backing device r2wpar_w1.2458bd43d1f3116046180e5e0e361ca7 Physloc Mirrored N/A __END_RAW__ use strict; use warnings; use File::Find; use Mail::Mailer; use Test::More tests => 2; use vars ('*name', '*dir', '*prune'); *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; $| = 1; my $regex = qr/\-$|^svsa.*$|^mirrored.*|^physloc.*|^$/i; my (%lsmap15a,$lsm15a,$client15a,$status15a,$bdev15a,$lsmap15a,$lsm15A +); open (LSMAP15A, "+< $lsmap15a") or die $!; while ( $lsm15a = (<LSMAP15A>) ) { next if $lsm15a =~ m/$regex/; ($lsm15A = $lsm15a) =~ s/\-//g; if ( $lsm15a =~ m/vtopt\d+/i ) { my $skip = 3; <LSMAP15A> while $skip-- >0 and not eof LSMAP15A; next; } if ( $lsm15a =~ /^vhost\d+\s+\w+\.\d+\w\.\w+\-\w+\-\w+\s+(0x\w+$)/ +i ) { $client15a = $1; } if ( $lsm15a =~ /^status\s+(\w+$)/i ) { $status15a = $1; push ( @{$lsmap15a{$client15a}}, $status15a ); next; } if ( $lsm15A =~ /^backing\sdevice\s+(\w+_\w+\.\w+$)/i ) { $bdev15a = $1; push ( @{$lsmap15a{$client15a}}, $bdev15a ); next; } } print RLOG "\n"; Test::More->builder->output( $runlog ); Test::More->builder->failure_output( $errlog ); is_deeply(\%lsmap15a, \%lsmap15b, 'vios15a-vios15b-map-compare' ); -s $errlog ? __mailme($contacts, $mesg, $errlog) : sleep 1; ### print w/no sort ### #for my $clientdataA ( sort keys %lsmap15a ) { # print RLOG join ("\n\n", "$clientdataA\t==> #\n\t@{$lsmap15a{$clientdataA}}\n\n"); #} ### print with sort ### foreach( sort { $a->[1] cmp $b->[1] } map { [ $_, $lsmap15a{$_}->[1] ] } keys %lsmap15a) { print join "\n", $_->[0],' => ',@{$lsmap15a{$_->[0]} }; print "\n\n"; }

In reply to sorted HoA, now what? by teamassociated

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.