I have this hash however I cannot for the life of me figure out how to apply sort to it. I have posted part of the hash but enough to make my point. I need to sort by the forth array value ie: $licensehash{CI}{CI_CTAG}[3]; Any ideas out there? Bonus: one line foreach loop.
our %licensehash = (
CI => {
CI_CTAG => ['','',"", "Customer Name", 1, '[^0-9a-zA-Z\-]', [@
+new_license_versions]],
CI_CID => ['','',"", "Chassis Serial", 1, '[^0-9a-zA-Z]', [@ne
+w_license_versions]],
CI_UID1 => ['','',"", "MAC 1/UUID", 0, '[^0-9a-zA-Z:-]', [$iTX
+_2_7_VERSION, $iTX_SBB_VERSION_val]],
CI_UID2 => ['','',"", "MAC 2", 0, '[^0-9a-zA-Z:-]', [$iTX_2_7_
+VERSION]],
CI_SER => ['','',"", "Lenovo Serial", 0, '[^0-9a-zA-Z]', [$iTX
+_Lenovo_VERSION_val]],
CI_UUID => ['','',"", "Lenovo UUID", 0, '[^0-9a-zA-Z]', [$iTX_
+Lenovo_VERSION_val]],
CI_E => ['','',"0", "Epoc", 0, '[^0-9]', [@new_license_version
+s]], #0 unlicensed, 1 first license
},
COM => {
COM_PV => ['','',$iTX_SBB_VERSION_val, "iTX Version", 1, '[^0-
+9.]', [@new_license_versions]],
COM_MV => ['','',$VERSION, "LMU Version", 0, '[^0-9.]', [@new_
+license_versions]],
COM_KT => ['','',"MASTER", "Key Type", 0, 'MASTER', [@new_lice
+nse_versions]],
COM_CD => ['','',sub{sprintf '%04d-%02d-%02d', $_[5]+1900, $_[
+4]+1, $_[3]}->(localtime), "Creation Date", 0, '[^0-9\-]', [@new_lice
+nse_versions]],
COM_USER => ['','',sub{qx"echo %username%"}, "Creation User",
+0, '[^0-9a-zA-Z\-]', [@new_license_versions]],
},
ISCSI => {
ISCSI_T => ['','',"-1", "iSCSI", 1, "-1,89478485", [@new_licen
+se_versions]],
},
NAS => {
NAS_T => ['','',"0", "NAS", 1, "-1,89478485", [$iTX_Lenovo_VER
+SION_val, $iTX_2_7_VERSION]],
},
RPL => {
RPL_T => ['','',"-1", "Sync Replication", 1, "-1,89478485", [@
+new_license_versions]],
},
);
#Help/fix me please
foreach my $tag (keys %licensehash) {
foreach my $type (keys %{$licensehash{$tag}}) {
print "$licensehash{$tag}{$type}[3]: $licensehash{$tag}{$type}
+[0]";
}
}